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 7d50ff96..be8c54bf 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -163,13 +163,7 @@ public class BungeeCord extends ProxyServer pluginManager.enablePlugins(); - for ( ListenerInfo info : config.getListeners() ) - { - $().info( "Listening on " + info.getHost() ); - ListenThread listener = new ListenThread( info ); - listener.start(); - listeners.add( listener ); - } + startListeners(); saveThread.scheduleAtFixedRate( new TimerTask() { @@ -183,11 +177,25 @@ public class BungeeCord extends ProxyServer new Metrics().start(); } - @Override - public void stop() + public void startListeners() { - this.isRunning = false; + for ( ListenerInfo info : config.getListeners() ) + { + try + { + ListenThread listener = new ListenThread( info ); + listener.start(); + listeners.add( listener ); + $().info( "Listening on " + info.getHost() ); + } catch ( IOException ex ) + { + $().log( Level.SEVERE, "Could not start listener " + info, ex ); + } + } + } + public void stopListeners() + { for ( ListenThread listener : listeners ) { $().log( Level.INFO, "Closing listen thread {0}", listener.socket ); @@ -200,7 +208,15 @@ public class BungeeCord extends ProxyServer $().severe( "Could not close listen thread" ); } } + listeners.clear(); + } + @Override + public void stop() + { + this.isRunning = false; + + stopListeners(); $().info( "Closing pending connections" ); threadPool.shutdown(); 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 b5ef7bbc..b02d76eb 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 @@ -17,6 +17,8 @@ public class CommandReload extends Command public void execute(CommandSender sender, String[] args) { BungeeCord.getInstance().config.load(); + BungeeCord.getInstance().stopListeners(); + BungeeCord.getInstance().startListeners(); sender.sendMessage( ChatColor.GREEN + "Reloaded config, please restart if you have any issues" ); } }