Whenever a chunk is loaded on the server, a check will now be run to make sure the border-monitoring task is still running like it should be. It will be restarted if necessary.

This commit is contained in:
Brettflan 2012-11-11 05:07:27 -06:00
parent e6d7e33d6b
commit 024c68a14f
2 changed files with 17 additions and 0 deletions

View File

@ -236,6 +236,12 @@ public class Config
public static boolean isBorderTimerRunning()
{
if (borderTask == -1) return false;
return (plugin.getServer().getScheduler().isQueued(borderTask) || plugin.getServer().getScheduler().isCurrentlyRunning(borderTask));
}
public static void StartBorderTimer()
{
StopBorderTimer();

View File

@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.Location;
@ -22,4 +23,14 @@ public class WBListener implements Listener
if (newLoc != null)
event.setTo(newLoc);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onChunkLoad(ChunkLoadEvent event)
{
// make sure our border monitoring task is still running like it should
if (Config.isBorderTimerRunning()) return;
Config.LogWarn("Border-checking task was not running! Something on your server apparently killed it. It will now be restarted.");
Config.StartBorderTimer();
}
}