#2280: Console usage of /server

This commit is contained in:
md_5 2017-10-26 21:11:56 +11:00
parent 8d49424226
commit ec4279eeb4

View File

@ -31,21 +31,20 @@ public class CommandServer extends Command implements TabExecutor
@Override
public void execute(CommandSender sender, String[] args)
{
if ( !( sender instanceof ProxiedPlayer ) )
{
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
Map<String, ServerInfo> servers = ProxyServer.getInstance().getServers();
if ( args.length == 0 )
{
player.sendMessage( ProxyServer.getInstance().getTranslation( "current_server", player.getServer().getInfo().getName() ) );
if ( sender instanceof ProxiedPlayer )
{
sender.sendMessage( ProxyServer.getInstance().getTranslation( "current_server", ( (ProxiedPlayer) sender ).getServer().getInfo().getName() ) );
}
TextComponent serverList = new TextComponent( ProxyServer.getInstance().getTranslation( "server_list" ) );
serverList.setColor( ChatColor.GOLD );
boolean first = true;
for ( ServerInfo server : servers.values() )
{
if ( server.canAccess( player ) )
if ( server.canAccess( sender ) )
{
TextComponent serverTextComponent = new TextComponent( first ? server.getName() : ", " + server.getName() );
int count = server.getPlayers().size();
@ -58,9 +57,15 @@ public class CommandServer extends Command implements TabExecutor
first = false;
}
}
player.sendMessage( serverList );
sender.sendMessage( serverList );
} else
{
if ( !( sender instanceof ProxiedPlayer ) )
{
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
ServerInfo server = servers.get( args[0] );
if ( server == null )
{