From 8aab30ab28a4fa428c70ae9db44463d33b29985a Mon Sep 17 00:00:00 2001 From: Stabrinai <61693182+Stabrinai@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:25:26 +0800 Subject: [PATCH] Fixed FoliaScheduler RuntimeException Fixed FoliaScheduler.runAtFixedRate() Fixed FoliaScheduler.runDelayed() --- .../api/utils/scheduler/folia/FoliaScheduler.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/src/main/java/fr/euphyllia/skyllia/api/utils/scheduler/folia/FoliaScheduler.java b/api/src/main/java/fr/euphyllia/skyllia/api/utils/scheduler/folia/FoliaScheduler.java index 2fddc4c..7d711bc 100644 --- a/api/src/main/java/fr/euphyllia/skyllia/api/utils/scheduler/folia/FoliaScheduler.java +++ b/api/src/main/java/fr/euphyllia/skyllia/api/utils/scheduler/folia/FoliaScheduler.java @@ -61,6 +61,12 @@ public void runAtFixedRate(@NotNull SchedulerType schedulerType, @Nullable Objec mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask); callBack.run(schedulerTask); }, initialDelayTicks, periodTicks); + } else if (chunkOrLocOrEntity instanceof MultipleRecords.WorldChunk worldChunk) { + Bukkit.getRegionScheduler().runAtFixedRate(this.plugin, worldChunk.world(), worldChunk.chunkX(), worldChunk.chunkZ(), task -> { + SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task); + mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask); + callBack.run(schedulerTask); + }, initialDelayTicks, periodTicks); } else { throw new RuntimeException("Object can only be Location or Chunk"); } @@ -120,6 +126,12 @@ public void runDelayed(@NotNull SchedulerType schedulerType, @Nullable Object ch mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask); callBack.run(schedulerTask); }, delayTicks); + } else if (chunkOrLocOrEntity instanceof MultipleRecords.WorldChunk worldChunk) { + Bukkit.getRegionScheduler().runDelayed(this.plugin, worldChunk.world(), worldChunk.chunkX(), worldChunk.chunkZ(), task -> { + SchedulerTaskInter schedulerTask = new FoliaSchedulerTask(task); + mapSchedulerTask.put(schedulerTask.getTaskId(), schedulerTask); + callBack.run(schedulerTask); + }, delayTicks); } else { throw new RuntimeException("Object can only be Location or Chunk"); }