Add reason for stopping and extra arguments.

This commit is contained in:
md_5 2015-02-14 18:33:49 +11:00
parent 415d5860e4
commit 2055c98ebe
3 changed files with 22 additions and 2 deletions

View File

@ -147,6 +147,13 @@ public abstract class ProxyServer
*/ */
public abstract void stop(); 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. * Start this instance so that it may accept connections.
* *

View File

@ -334,6 +334,12 @@ public class BungeeCord extends ProxyServer
@Override @Override
public void stop() public void stop()
{
stop( getTranslation( "restart" ) );
}
@Override
public void stop(final String reason)
{ {
new Thread( "Shutdown Thread" ) new Thread( "Shutdown Thread" )
{ {
@ -353,7 +359,7 @@ public class BungeeCord extends ProxyServer
getLogger().log( Level.INFO, "Disconnecting {0} connections", connections.size() ); getLogger().log( Level.INFO, "Disconnecting {0} connections", connections.size() );
for ( UserConnection user : connections.values() ) for ( UserConnection user : connections.values() )
{ {
user.disconnect( getTranslation( "restart" ) ); user.disconnect( reason );
} }
} finally } finally
{ {

View File

@ -1,5 +1,6 @@
package net.md_5.bungee.command; package net.md_5.bungee.command;
import com.google.common.base.Joiner;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Command;
@ -19,6 +20,12 @@ public class CommandEnd extends Command
@Override @Override
public void execute(CommandSender sender, String[] args) 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 ) );
}
} }
} }