Custom glist formatting

This commit is contained in:
md_5 2013-09-29 18:45:11 +10:00
parent dd06937a3b
commit b541e7aa76
4 changed files with 9 additions and 23 deletions

View File

@ -53,7 +53,7 @@ public abstract class ProxyServer
*
* @return the localized string
*/
public abstract String getTranslation(String name);
public abstract String getTranslation(String name, Object... args);
/**
* Gets the main logger which can be used as a suitable replacement for

View File

@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
@ -368,12 +369,12 @@ public class BungeeCord extends ProxyServer
}
@Override
public String getTranslation(String name)
public String getTranslation(String name, Object... args)
{
String translation = "<translation '" + name + "' missing>";
try
{
translation = bundle.getString( name );
translation = MessageFormat.format( bundle.getString( name ), args );
} catch ( MissingResourceException ex )
{
}

View File

@ -1,7 +1,6 @@
package net.md_5.bungee.command;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import net.md_5.bungee.Util;
@ -33,31 +32,16 @@ public class CommandList extends Command
continue;
}
Collection<ProxiedPlayer> serverPlayers = server.getPlayers();
StringBuilder message = new StringBuilder();
message.append( ChatColor.GREEN );
message.append( "[" );
message.append( server.getName() );
message.append( "] " );
message.append( ChatColor.YELLOW );
message.append( "(" );
message.append( serverPlayers.size() );
message.append( "): " );
message.append( ChatColor.RESET );
List<String> players = new ArrayList<>();
for ( ProxiedPlayer player : serverPlayers )
for ( ProxiedPlayer player : server.getPlayers() )
{
players.add( player.getDisplayName() );
}
Collections.sort( players, String.CASE_INSENSITIVE_ORDER );
message.append( Util.format( players, ChatColor.RESET + ", " ) );
sender.sendMessage( message.toString() );
sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), server.getPlayers().size(), Util.format( players, ChatColor.RESET + ", " ) ) );
}
sender.sendMessage( ProxyServer.getInstance().getTranslation( "total_players" ) + ProxyServer.getInstance().getOnlineCount() );
sender.sendMessage( ProxyServer.getInstance().getTranslation( "total_players", ProxyServer.getInstance().getOnlineCount() ) );
}
}

View File

@ -1,6 +1,7 @@
alert=\u00a78[\u00a74Alert\u00a78]\u00a7r
already_connected=\u00a7cYou are already connected to this server
already_connecting=\u00a7cAlready connecting to this server!
command_list=\u00a7a[{0}] \u00a7e({1}): \u00a7r{2}
connect_kick=\u00a7cKicked whilst connecting to
current_server=\u00a76You are currently connected to
fallback_kick=\u00a7cCould not connect to default server, please try again later:
@ -17,4 +18,4 @@ restart=[Proxy] Proxy restarting.
server_kick=[Kicked]
server_list=\u00a76You may connect to the following servers at this time:
server_went_down=\u00a7cThe server you were previously on went down, you have been connected to the lobby
total_players=Total players online:
total_players=Total players online: {0}