Skip to content

Commit

Permalink
Merge pull request #28 from Stabrinai/patch-1
Browse files Browse the repository at this point in the history
Fixed FoliaScheduler RuntimeException when use MultipleRecords.WorldChunk
  • Loading branch information
Euphillya authored Feb 28, 2024
2 parents 2debb05 + 8aab30a commit e6fd525
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit e6fd525

Please sign in to comment.