Unified shutdown functions for Telnet.

This commit is contained in:
MobiusDev 2018-05-01 16:46:21 +00:00
parent af70b6bc0c
commit b3c5f24b25
39 changed files with 53 additions and 629 deletions

View File

@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@ -400,7 +400,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@ -83,65 +83,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@ -382,7 +323,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();

View File

@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@ -408,7 +408,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@ -83,65 +83,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@ -382,7 +323,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();

View File

@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@ -408,7 +408,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@ -83,65 +83,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@ -382,7 +323,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();

View File

@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@ -408,7 +408,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@ -83,65 +83,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@ -382,7 +323,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();

View File

@ -55,11 +55,7 @@ public class Shutdown extends Thread
SIGTERM("Terminating"),
SHUTDOWN("Shutting down"),
RESTART("Restarting"),
ABORT("Aborting"),
TASK_SHUT("Shuting down"),
TASK_RES("Restarting"),
TELL_SHUT("Shuting down"),
TELL_RES("Restarting");
ABORT("Aborting");
private final String _modeText;
@ -93,78 +89,14 @@ public class Shutdown extends Thread
public static final int GM_RESTART = 2;
/** 3 */
public static final int ABORT = 3;
/** 4 */
public static final int TASK_SHUTDOWN = 4;
/** 5 */
public static final int TASK_RESTART = 5;
/** 6 */
public static final int TELL_SHUTDOWN = 6;
/** 7 */
public static final int TELL_RESTART = 7;
private static final String[] MODE_TEXT =
{
"SIGTERM",
"shutting down",
"restarting",
"aborting", // standart
"shutting down",
"restarting", // task
"shutting down",
"restarting"
}; // telnet
/**
* This function starts a shutdown count down from Telnet (Copied from Function startShutdown())
* @param IP Which Issued shutdown command
* @param seconds seconds until shutdown
* @param restart true if the server will restart after shutdown
*/
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
final Announcements _an = Announcements.getInstance();
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_an.announceToAll("Server is " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
if (restart)
{
_shutdownMode = TELL_RESTART;
}
else
{
_shutdownMode = TELL_SHUTDOWN;
}
if (_shutdownMode > 0)
{
_an.announceToAll("Server is " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_an.announceToAll("Please exit game now!!");
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart, false, true);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
Announcements _an = Announcements.getInstance();
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
_an.announceToAll("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!");
if (_counterInstance != null)
{
_counterInstance._abort();
}
}
"aborting"
};
/**
* Default constructor is only used internal to create the shutdown-hook instance
@ -180,10 +112,8 @@ public class Shutdown extends Thread
* This creates a count down instance of Shutdown.
* @param seconds how many seconds until shutdown
* @param restart true is the server shall restart after shutdown
* @param task
* @param telnet
*/
public Shutdown(int seconds, boolean restart, boolean task, boolean telnet)
private Shutdown(int seconds, boolean restart)
{
if (seconds < 0)
{
@ -192,30 +122,11 @@ public class Shutdown extends Thread
_secondsShut = seconds;
if (restart)
{
if (!task)
{
_shutdownMode = GM_RESTART;
}
else if (telnet)
{
_shutdownMode = TELL_RESTART;
}
else
{
_shutdownMode = TASK_RESTART;
}
}
else if (!task)
{
_shutdownMode = GM_SHUTDOWN;
}
else if (telnet)
{
_shutdownMode = TELL_SHUTDOWN;
_shutdownMode = GM_RESTART;
}
else
{
_shutdownMode = TASK_SHUTDOWN;
_shutdownMode = GM_SHUTDOWN;
}
_shutdownStarted = false;
@ -254,10 +165,6 @@ public class Shutdown extends Thread
@Override
public void run()
{
/*
* // disallow new logins try { //Doesnt actually do anything //Server.gameServer.getLoginController().setMaxAllowedOnlinePlayers(0); } catch(Throwable t) { if(Config.ENABLE_ALL_EXCEPTIONS) t.printStackTrace(); }
*/
if (this == _instance)
{
closeServer();
@ -287,14 +194,7 @@ public class Shutdown extends Thread
{
Announcements _an = Announcements.getInstance();
if (activeChar != null)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
}
else
{
LOGGER.warning("External Service issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
}
LOGGER.warning((activeChar != null ? "GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ")" : "Server") + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
if (restart)
{
@ -317,7 +217,7 @@ public class Shutdown extends Thread
}
// the main instance should only run for shutdown hook, so we start a new instance
_counterInstance = new Shutdown(seconds, restart, false, false);
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
@ -334,14 +234,7 @@ public class Shutdown extends Thread
{
Announcements _an = Announcements.getInstance();
if (activeChar != null)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
}
else
{
LOGGER.warning("External Service issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
}
LOGGER.warning((activeChar != null ? "GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ")" : "Server") + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
_an.announceToAll("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!");
@ -351,14 +244,6 @@ public class Shutdown extends Thread
}
}
/**
* set the shutdown mode
* @param mode what mode shall be set
*/
/*
* private void setMode(int mode) { _shutdownMode = mode; }
*/
/**
* set shutdown mode to ABORT
*/
@ -425,8 +310,7 @@ public class Shutdown extends Thread
private void closeServer()
{
// last byebye, save all data and quit this server
// logging doesnt work here :(
// Save all data and quit this server.
_shutdownStarted = true;
try
@ -494,32 +378,10 @@ public class Shutdown extends Thread
LOGGER.info("[STATUS] Server shutdown successfully.");
// server will quit, when this function ends.
/*
* switch (_shutdownMode) { case GM_SHUTDOWN: _instance.setMode(GM_SHUTDOWN); System.exit(0); break; case GM_RESTART: _instance.setMode(GM_RESTART); System.exit(2); break; case TASK_SHUTDOWN: _instance.setMode(TASK_SHUTDOWN); System.exit(4); break; case TASK_RESTART:
* _instance.setMode(TASK_RESTART); System.exit(5); break; case TELL_SHUTDOWN: _instance.setMode(TELL_SHUTDOWN); System.exit(6); break; case TELL_RESTART: _instance.setMode(TELL_RESTART); System.exit(7); break; }
*/
if (_instance._shutdownMode == GM_RESTART)
{
Runtime.getRuntime().halt(2);
}
else if (_instance._shutdownMode == TASK_RESTART)
{
Runtime.getRuntime().halt(5);
}
else if (_instance._shutdownMode == TASK_SHUTDOWN)
{
Runtime.getRuntime().halt(4);
}
else if (_instance._shutdownMode == TELL_RESTART)
{
Runtime.getRuntime().halt(7);
}
else if (_instance._shutdownMode == TELL_SHUTDOWN)
{
Runtime.getRuntime().halt(6);
}
else
{
Runtime.getRuntime().halt(0);
@ -549,26 +411,6 @@ public class Shutdown extends Thread
LOGGER.info("GM restart received. Restarting NOW!");
break;
}
case TASK_SHUTDOWN:
{
LOGGER.info("Auto task shutdown received. Shutting down NOW!");
break;
}
case TASK_RESTART:
{
LOGGER.info("Auto task restart received. Restarting NOW!");
break;
}
case TELL_SHUTDOWN:
{
LOGGER.info("Telnet shutdown received. Shutting down NOW!");
break;
}
case TELL_RESTART:
{
LOGGER.info("Telnet restart received. Restarting NOW!");
break;
}
}
try
{
@ -640,7 +482,7 @@ public class Shutdown extends Thread
// Save data CountStore
TradeController.getInstance().dataCountStore();
LOGGER.info("TradeController: All count Item Saved");
LOGGER.info("TradeController: All count Item Saved!!");
// Save Olympiad status
try
@ -661,11 +503,11 @@ public class Shutdown extends Thread
// Save Fishing tournament data
FishingChampionshipManager.getInstance().shutdown();
LOGGER.info("Fishing Championship data has been saved.");
LOGGER.info("Fishing Championship data has been saved!!");
// Schemes save.
BufferTable.getInstance().saveSchemes();
LOGGER.info("BufferTable data has been saved.");
LOGGER.info("BufferTable data has been saved!!");
// Save all global (non-player specific) Quest data that needs to persist after reboot
if (!Config.ALT_DEV_NO_QUESTS)
@ -744,5 +586,4 @@ public class Shutdown extends Thread
}
}
}
}

View File

@ -48,8 +48,6 @@ public final class TaskRestart extends Task
public void onTimeElapsed(ExecutedTask task)
{
LOGGER.info("[GlobalTask] Server Restart launched.");
final Shutdown handler = new Shutdown(Integer.valueOf(task.getParams()[2]), true, true, false);
handler.start();
Shutdown.getInstance().startShutdown(null, Integer.valueOf(task.getParams()[2]), true);
}
}

View File

@ -48,8 +48,6 @@ public class TaskShutdown extends Task
public void onTimeElapsed(ExecutedTask task)
{
LOGGER.info("[GlobalTask] Server Shutdown launched.");
final Shutdown handler = new Shutdown(Integer.valueOf(task.getParams()[2]), false, true, false);
handler.start();
Shutdown.getInstance().startShutdown(null, Integer.valueOf(task.getParams()[2]), false);
}
}

View File

@ -456,7 +456,7 @@ public class GameStatusThread extends Thread
try
{
final int val = Integer.parseInt(_usrCommand.substring(9));
Shutdown.getInstance().startTelnetShutdown(_cSocket.getInetAddress().getHostAddress(), val, false);
Shutdown.getInstance().startShutdown(null, val, false);
_print.println("Server Will Shutdown In " + val + " Seconds!");
_print.println("Type \"abort\" To Abort Shutdown!");
}
@ -474,7 +474,7 @@ public class GameStatusThread extends Thread
try
{
final int val = Integer.parseInt(_usrCommand.substring(8));
Shutdown.getInstance().startTelnetShutdown(_cSocket.getInetAddress().getHostAddress(), val, true);
Shutdown.getInstance().startShutdown(null, val, true);
_print.println("Server Will Restart In " + val + " Seconds!");
_print.println("Type \"abort\" To Abort Restart!");
}
@ -489,7 +489,7 @@ public class GameStatusThread extends Thread
}
else if (_usrCommand.startsWith("abort"))
{
Shutdown.getInstance().telnetAbort(_cSocket.getInetAddress().getHostAddress());
Shutdown.getInstance().abort(null);
_print.println("OK! - Shutdown/Restart Aborted.");
}
else if (_usrCommand.equals("quit"))

View File

@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@ -405,7 +405,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@ -84,65 +84,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@ -383,7 +324,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();

View File

@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@ -399,7 +399,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@ -83,65 +83,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@ -382,7 +323,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();

View File

@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@ -399,7 +399,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@ -83,65 +83,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@ -382,7 +323,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();