changes to tab completion
* PacketCBTabComplete: options for completion should be seperated by NUL * PluginManager: append an empty argument to arguments if command ends with a whitespace (this will match all suggestions) * PlayerCommand: suggest only matching players instead of all players
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.command;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@@ -24,12 +25,20 @@ public abstract class PlayerCommand extends Command implements TabExecutor
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args)
|
||||
{
|
||||
return Iterables.transform( ProxyServer.getInstance().getPlayers(), new Function<ProxiedPlayer, String>()
|
||||
final String lastArg = ( args.length > 0 ) ? args[args.length - 1] : "";
|
||||
return Iterables.transform( Iterables.filter( ProxyServer.getInstance().getPlayers(), new Predicate<ProxiedPlayer>()
|
||||
{
|
||||
@Override
|
||||
public String apply(ProxiedPlayer input)
|
||||
public boolean apply(ProxiedPlayer player)
|
||||
{
|
||||
return input.getDisplayName();
|
||||
return player.getName().startsWith( lastArg );
|
||||
}
|
||||
} ), new Function<ProxiedPlayer, String>()
|
||||
{
|
||||
@Override
|
||||
public String apply(ProxiedPlayer player)
|
||||
{
|
||||
return player.getName();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
Reference in New Issue
Block a user