diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 795e9d6bd6..d38376d039 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -34,6 +34,7 @@ import io.netty.util.ResourceLeakDetector; import net.md_5.bungee.conf.Configuration; import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.io.PrintStream; import java.net.InetSocketAddress; @@ -46,6 +47,7 @@ import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; +import java.util.PropertyResourceBundle; import java.util.ResourceBundle; import java.util.Timer; import java.util.TimerTask; @@ -104,7 +106,8 @@ public class BungeeCord extends ProxyServer /** * Localization bundle. */ - public ResourceBundle bundle; + private ResourceBundle baseBundle; + private ResourceBundle customBundle; public EventLoopGroup eventLoops; /** * locations.yml save thread. @@ -185,10 +188,18 @@ public BungeeCord() throws IOException try { - bundle = ResourceBundle.getBundle( "messages" ); + baseBundle = ResourceBundle.getBundle( "messages" ); } catch ( MissingResourceException ex ) { - bundle = ResourceBundle.getBundle( "messages", Locale.ENGLISH ); + baseBundle = ResourceBundle.getBundle( "messages", Locale.ENGLISH ); + } + File file = new File( "messages.properties" ); + if ( file.isFile() ) + { + try ( FileReader rd = new FileReader( file ) ) + { + customBundle = new PropertyResourceBundle( rd ); + } } // This is a workaround for quite possibly the weirdest bug I have ever encountered in my life! @@ -468,7 +479,7 @@ public String getTranslation(String name, Object... args) String translation = ""; try { - translation = MessageFormat.format( bundle.getString( name ), args ); + translation = MessageFormat.format( customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name ), args ); } catch ( MissingResourceException ex ) { } @@ -588,7 +599,7 @@ public int getProtocolVersion() @Override public String getGameVersion() { - return Joiner.on(", ").join(ProtocolConstants.SUPPORTED_VERSIONS); + return Joiner.on( ", " ).join( ProtocolConstants.SUPPORTED_VERSIONS ); } @Override