Fix issue #251 - hidden servers in list command

This commit is contained in:
md_5 2013-04-12 12:40:36 +10:00
parent 5592f81e97
commit 0c144c38db
2 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.Synchronized; import lombok.Synchronized;
import net.md_5.bungee.api.Callback; import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ServerPing; import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -92,7 +93,7 @@ public abstract class ServerInfo
* @param player the player to check access for * @param player the player to check access for
* @return whether access is granted to this server * @return whether access is granted to this server
*/ */
public boolean canAccess(ProxiedPlayer player) public boolean canAccess(CommandSender player)
{ {
return !restricted || player.hasPermission( "bungeecord.server." + name ); return !restricted || player.hasPermission( "bungeecord.server." + name );
} }

View File

@ -28,6 +28,11 @@ public class CommandList extends Command
{ {
for ( ServerInfo server : ProxyServer.getInstance().getServers().values() ) for ( ServerInfo server : ProxyServer.getInstance().getServers().values() )
{ {
if ( !server.canAccess( sender ) )
{
continue;
}
Collection<ProxiedPlayer> serverPlayers = server.getPlayers(); Collection<ProxiedPlayer> serverPlayers = server.getPlayers();
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();