Make greload reload custom messages.properties

This commit is contained in:
md_5 2017-11-10 11:21:58 +11:00
parent fbc5f514e2
commit 2e826a15e7
2 changed files with 17 additions and 8 deletions

View File

@ -189,14 +189,7 @@ public class BungeeCord extends ProxyServer
{ {
baseBundle = ResourceBundle.getBundle( "messages", Locale.ENGLISH ); baseBundle = ResourceBundle.getBundle( "messages", Locale.ENGLISH );
} }
File file = new File( "messages.properties" ); reloadMessages();
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! // This is a workaround for quite possibly the weirdest bug I have ever encountered in my life!
// When jansi attempts to extract its natives, by default it tries to extract a specific version, // When jansi attempts to extract its natives, by default it tries to extract a specific version,
@ -484,6 +477,21 @@ public class BungeeCord extends ProxyServer
return ( BungeeCord.class.getPackage().getImplementationVersion() == null ) ? "unknown" : BungeeCord.class.getPackage().getImplementationVersion(); return ( BungeeCord.class.getPackage().getImplementationVersion() == null ) ? "unknown" : BungeeCord.class.getPackage().getImplementationVersion();
} }
public void reloadMessages()
{
File file = new File( "messages.properties" );
if ( file.isFile() )
{
try ( FileReader rd = new FileReader( file ) )
{
customBundle = new PropertyResourceBundle( rd );
} catch ( IOException ex )
{
getLogger().log( Level.SEVERE, "Could not load custom messages.properties", ex );
}
}
}
@Override @Override
public String getTranslation(String name, Object... args) public String getTranslation(String name, Object... args)
{ {

View File

@ -18,6 +18,7 @@ public class CommandReload extends Command
public void execute(CommandSender sender, String[] args) public void execute(CommandSender sender, String[] args)
{ {
BungeeCord.getInstance().config.load(); BungeeCord.getInstance().config.load();
BungeeCord.getInstance().reloadMessages();
BungeeCord.getInstance().stopListeners(); BungeeCord.getInstance().stopListeners();
BungeeCord.getInstance().startListeners(); BungeeCord.getInstance().startListeners();
BungeeCord.getInstance().getPluginManager().callEvent( new ProxyReloadEvent( sender ) ); BungeeCord.getInstance().getPluginManager().callEvent( new ProxyReloadEvent( sender ) );