From 2055c98ebeaeaa0ecae7362130fe2c2b681f2cb7 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 14 Feb 2015 18:33:49 +1100 Subject: [PATCH] Add reason for stopping and extra arguments. --- api/src/main/java/net/md_5/bungee/api/ProxyServer.java | 7 +++++++ proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 8 +++++++- .../main/java/net/md_5/bungee/command/CommandEnd.java | 9 ++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java index 7b08d2f6..4c191f25 100644 --- a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java +++ b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java @@ -147,6 +147,13 @@ public abstract class ProxyServer */ public abstract void stop(); + /** + * Gracefully mark this instance for shutdown. + * + * @param reason the reason for stopping. This will be shown to players. + */ + public abstract void stop(String reason); + /** * Start this instance so that it may accept connections. * 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 50ab8d2c..bb1c0d30 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -334,6 +334,12 @@ public class BungeeCord extends ProxyServer @Override public void stop() + { + stop( getTranslation( "restart" ) ); + } + + @Override + public void stop(final String reason) { new Thread( "Shutdown Thread" ) { @@ -353,7 +359,7 @@ public class BungeeCord extends ProxyServer getLogger().log( Level.INFO, "Disconnecting {0} connections", connections.size() ); for ( UserConnection user : connections.values() ) { - user.disconnect( getTranslation( "restart" ) ); + user.disconnect( reason ); } } finally { diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandEnd.java b/proxy/src/main/java/net/md_5/bungee/command/CommandEnd.java index ae75ba96..d87d0b95 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandEnd.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandEnd.java @@ -1,5 +1,6 @@ package net.md_5.bungee.command; +import com.google.common.base.Joiner; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.plugin.Command; @@ -19,6 +20,12 @@ public class CommandEnd extends Command @Override public void execute(CommandSender sender, String[] args) { - BungeeCord.getInstance().stop(); + if ( args.length == 0 ) + { + BungeeCord.getInstance().stop(); + } else + { + BungeeCord.getInstance().stop( Joiner.on( ' ' ).join( args ) ); + } } }