mirror of
https://github.com/PryPurity/WorldBorder.git
synced 2024-09-29 04:07:28 +02:00
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:
parent
e6d7e33d6b
commit
024c68a14f
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user