From 2e826a15e73166538093514b09281db3c44ca896 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 10 Nov 2017 11:21:58 +1100 Subject: [PATCH] Make greload reload custom messages.properties --- .../main/java/net/md_5/bungee/BungeeCord.java | 24 ++++++++++++------- .../md_5/bungee/command/CommandReload.java | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) 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 b4c8bcfc..43c8862f 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -189,14 +189,7 @@ public class BungeeCord extends ProxyServer { 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 ); - } - } + reloadMessages(); // 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, @@ -484,6 +477,21 @@ public class BungeeCord extends ProxyServer 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 public String getTranslation(String name, Object... args) { diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java b/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java index cbbe03c7..771ef5dc 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandReload.java @@ -18,6 +18,7 @@ public class CommandReload extends Command public void execute(CommandSender sender, String[] args) { BungeeCord.getInstance().config.load(); + BungeeCord.getInstance().reloadMessages(); BungeeCord.getInstance().stopListeners(); BungeeCord.getInstance().startListeners(); BungeeCord.getInstance().getPluginManager().callEvent( new ProxyReloadEvent( sender ) );