Server command completion
This commit is contained in:
		| @@ -1,16 +1,23 @@ | ||||
| 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 java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import net.md_5.bungee.api.CommandSender; | ||||
| import net.md_5.bungee.api.ProxyServer; | ||||
| import net.md_5.bungee.api.config.ServerInfo; | ||||
| import net.md_5.bungee.api.connection.ProxiedPlayer; | ||||
| import net.md_5.bungee.api.plugin.Command; | ||||
| import net.md_5.bungee.api.plugin.TabExecutor; | ||||
|  | ||||
| /** | ||||
|  * Command to list and switch a player between available servers. | ||||
|  */ | ||||
| public class CommandServer extends Command | ||||
| public class CommandServer extends Command implements TabExecutor | ||||
| { | ||||
|  | ||||
|     public CommandServer() | ||||
| @@ -60,4 +67,24 @@ public class CommandServer extends Command | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Iterable<String> onTabComplete(final CommandSender sender, String[] args) | ||||
|     { | ||||
|         return Iterables.transform( Iterables.filter( ProxyServer.getInstance().getServers().values(), new Predicate<ServerInfo>() | ||||
|         { | ||||
|             @Override | ||||
|             public boolean apply(ServerInfo input) | ||||
|             { | ||||
|                 return input.canAccess( sender ); | ||||
|             } | ||||
|         } ), new Function<ServerInfo, String>() | ||||
|         { | ||||
|             @Override | ||||
|             public String apply(ServerInfo input) | ||||
|             { | ||||
|                 return input.getName(); | ||||
|             } | ||||
|         } ); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 md_5
					md_5