Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #16 from SpigotMC/master
Browse files Browse the repository at this point in the history
SpigotMC#901: Better custom messages support
  • Loading branch information
Zartec committed Mar 24, 2016
2 parents 03488cd + f265f7c commit 46c2cd5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions proxy/src/main/java/net/md_5/bungee/BungeeCord.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -468,7 +479,7 @@ public String getTranslation(String name, Object... args)
String translation = "<translation '" + name + "' missing>";
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 )
{
}
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 46c2cd5

@Zartec
Copy link
Member Author

@Zartec Zartec commented on 46c2cd5 Mar 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ist gemerged

Please sign in to comment.