mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 12:46:05 +01:00
Add ResourceBundle localization
This commit is contained in:
parent
140830efe0
commit
30b2e5008b
@ -49,6 +49,13 @@ public abstract class ProxyServer
|
||||
*/
|
||||
public abstract String getVersion();
|
||||
|
||||
/**
|
||||
* Gets a localized string from the .properties file.
|
||||
*
|
||||
* @return the localized string
|
||||
*/
|
||||
public abstract String getTranslation( String name );
|
||||
|
||||
/**
|
||||
* Gets the main logger which can be used as a suitable replacement for
|
||||
* {@link System#out} and {@link System#err}.
|
||||
|
@ -24,6 +24,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -75,6 +76,10 @@ public class BungeeCord extends ProxyServer
|
||||
* Configuration.
|
||||
*/
|
||||
public final Configuration config = new Configuration();
|
||||
/**
|
||||
* Localization bundle.
|
||||
*/
|
||||
public final ResourceBundle bundle = ResourceBundle.getBundle( "messages_en" );
|
||||
/**
|
||||
* Thread pools.
|
||||
*/
|
||||
@ -272,7 +277,7 @@ public class BungeeCord extends ProxyServer
|
||||
getLogger().info( "Disconnecting " + connections.size() + " connections" );
|
||||
for ( UserConnection user : connections.values() )
|
||||
{
|
||||
user.disconnect( "Proxy restarting, brb." );
|
||||
user.disconnect( getTranslation( "restart" ) );
|
||||
}
|
||||
|
||||
getLogger().info( "Closing IO threads" );
|
||||
@ -290,7 +295,7 @@ public class BungeeCord extends ProxyServer
|
||||
getScheduler().cancel( plugin );
|
||||
}
|
||||
|
||||
getLogger().info( "Thank you and goodbye" );
|
||||
getLogger().info( getTranslation( "end" ) );
|
||||
System.exit( 0 );
|
||||
}
|
||||
|
||||
@ -319,6 +324,12 @@ public class BungeeCord extends ProxyServer
|
||||
return ( BungeeCord.class.getPackage().getImplementationVersion() == null ) ? "unknown" : BungeeCord.class.getPackage().getImplementationVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslation(String name)
|
||||
{
|
||||
return bundle.getString( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger()
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ public class DownstreamBridge extends PacketHandler
|
||||
|
||||
if ( !server.isObsolete() )
|
||||
{
|
||||
con.disconnect( "[Proxy] Lost connection to server D:" );
|
||||
con.disconnect( bungee.getTranslation( "lost_connection ") );
|
||||
}
|
||||
}
|
||||
|
||||
|
3
proxy/src/main/resources/messages_en.properties
Normal file
3
proxy/src/main/resources/messages_en.properties
Normal file
@ -0,0 +1,3 @@
|
||||
restart: [Proxy] Proxy restarting.
|
||||
lost_connection: [Proxy] Lost connection to server.
|
||||
end: Thank you, and goodbye.
|
Loading…
Reference in New Issue
Block a user