Fix Clans servers not restarting every night, display an uptime notification whenever Clans servers shut down for any reason, and remove unnecessary onDisables from the main ClansManager onDisable

This commit is contained in:
AlexTheCoder 2016-11-20 12:49:01 -05:00 committed by Shaun Bennett
parent 18992efa5a
commit 32c9900069
2 changed files with 16 additions and 6 deletions

View File

@ -200,6 +200,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private ClassManager _classManager;
private BannerManager _bannerManager;
private AmplifierManager _amplifierManager;
private RestartManager _restartManager;
private SafeLog _safeLog;
@ -463,7 +464,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_netherManager = new NetherManager(this);
_amplifierManager = new AmplifierManager(plugin);
new RestartManager(plugin);
_restartManager = new RestartManager(plugin);
}
@Override
@ -1207,10 +1208,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_worldEvent.onDisable();
_goldManager.onDisable();
_playTracker.onDisable();
_bannerManager.onDisable();
_amplifierManager.onDisable();
_netherManager.onDisable();
_safeLog.onDisable();
_restartManager.onDisable();
}
@EventHandler(priority = EventPriority.HIGHEST)

View File

@ -40,9 +40,10 @@ public class RestartManager extends MiniPlugin
_serverName = plugin.getConfig().getString("serverstatus.name");
_testServer = plugin.getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing");
if (inRestartZone(Calendar.HOUR_OF_DAY))
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if (inRestartZone(hour))
{
_restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - Calendar.HOUR_OF_DAY, TimeUnit.HOURS, TimeUnit.MILLISECONDS);
_restartUnlock = System.currentTimeMillis() + 1000 + UtilTime.convert(MAX_RESTART_TIME - hour, TimeUnit.HOURS, TimeUnit.MILLISECONDS);
}
else
{
@ -68,7 +69,7 @@ public class RestartManager extends MiniPlugin
private boolean tryRestartTime()
{
if (!inRestartZone(Calendar.HOUR_OF_DAY) || System.currentTimeMillis() < _restartUnlock)
if (!inRestartZone(Calendar.getInstance().get(Calendar.HOUR_OF_DAY)) || System.currentTimeMillis() < _restartUnlock)
{
return false;
}
@ -100,6 +101,15 @@ public class RestartManager extends MiniPlugin
return restart;
}
@Override
public void disable()
{
if (!_testServer)
{
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, "#clans-server-status", new SlackMessage("Clans Uptime", "crossed_swords", _serverName + " has shut down!"), true);
}
}
public void restart()
{
Bukkit.broadcastMessage(F.main("Clans", "This Clans server will be restarting in " + F.elem(UtilTime.MakeStr(120000)) + "!"));