Skip to content

Commit

Permalink
Update VisitPlayerCommand.java (#17)
Browse files Browse the repository at this point in the history
Added tab-complete for visit command.

Fixes #18
  • Loading branch information
nitrofenix committed Aug 8, 2022
1 parent f57feb0 commit 5f2f6e4
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,14 @@ else if (args.size() == 1 || bypass)
* @return List of strings that could be used to complete this command.
*/
@Override
public Optional<List<String>> tabComplete(User user, String alias, List<String> args)
{
// TODO: nice addition would be to autocomplete user names.
return super.tabComplete(user, alias, args);
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
if (lastArg.isEmpty()) {
// Don't show every player on the server. Require at least the first letter
return Optional.empty();
}
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
return Optional.of(Util.tabLimit(options, lastArg));
}


Expand Down

0 comments on commit 5f2f6e4

Please sign in to comment.