Delay processing of chunkloadevent

This commit is contained in:
fullwall 2019-07-07 14:44:08 +08:00
parent 530e175094
commit 82e4f2dcea
1 changed files with 11 additions and 1 deletions

View File

@ -142,7 +142,17 @@ public class EventListen implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
respawnAllFromCoord(new ChunkCoord(event.getChunk()));
Runnable runnable = new Runnable() {
@Override
public void run() {
respawnAllFromCoord(new ChunkCoord(event.getChunk()));
}
};
if (event instanceof Cancellable) {
runnable.run();
} else {
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), runnable);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)