Fix server command to properly tab complete, be case insensitive.

This commit is contained in:
md_5 2014-12-22 20:02:19 +11:00
parent 1711223b02
commit 2ab0715226

View File

@ -76,14 +76,16 @@ public class CommandServer extends Command implements TabExecutor
} }
@Override @Override
public Iterable<String> onTabComplete(final CommandSender sender, String[] args) public Iterable<String> onTabComplete(final CommandSender sender, final String[] args)
{ {
return ( args.length != 0 ) ? Collections.EMPTY_LIST : Iterables.transform( Iterables.filter( ProxyServer.getInstance().getServers().values(), new Predicate<ServerInfo>() return ( args.length != 0 ) ? Collections.EMPTY_LIST : Iterables.transform( Iterables.filter( ProxyServer.getInstance().getServers().values(), new Predicate<ServerInfo>()
{ {
private final String lower = args[0].toLowerCase();
@Override @Override
public boolean apply(ServerInfo input) public boolean apply(ServerInfo input)
{ {
return input.canAccess( sender ); return input.getName().toLowerCase().startsWith( lower ) && input.canAccess( sender );
} }
} ), new Function<ServerInfo, String>() } ), new Function<ServerInfo, String>()
{ {