diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandServer.java b/proxy/src/main/java/net/md_5/bungee/command/CommandServer.java index 0d87effb..69cfaf91 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandServer.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandServer.java @@ -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 onTabComplete(final CommandSender sender, String[] args) + { + return Iterables.transform( Iterables.filter( ProxyServer.getInstance().getServers().values(), new Predicate() + { + @Override + public boolean apply(ServerInfo input) + { + return input.canAccess( sender ); + } + } ), new Function() + { + @Override + public String apply(ServerInfo input) + { + return input.getName(); + } + } ); + } }