diff --git a/pom.xml b/pom.xml index b370ab2..e58595c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.lunadeer ColorfulMap - 2.0 + 2.1 jar ColorfulMap diff --git a/src/main/java/cn/lunadeer/colorfulmap/utils/Scheduler.java b/src/main/java/cn/lunadeer/colorfulmap/utils/Scheduler.java index 19cd329..136ed9e 100644 --- a/src/main/java/cn/lunadeer/colorfulmap/utils/Scheduler.java +++ b/src/main/java/cn/lunadeer/colorfulmap/utils/Scheduler.java @@ -26,74 +26,6 @@ public class Scheduler { } } - /** - * Run a task later - * - * @param task The task to run - * @param delay The delay in ticks (20 ticks = 1 second) - * @return The scheduled task - */ - public static void runTaskLater(Runnable task, long delay) { - if (delay <= 0) { - runTask(task); - return; - } - if (instance.isPaper) { - instance.plugin.getServer().getGlobalRegionScheduler().runDelayed(instance.plugin, (plugin) -> task.run(), delay); - } else { - instance.plugin.getServer().getScheduler().runTaskLater(instance.plugin, task, delay); - } - } - - /** - * Run a task - * - * @param task The task to run - * @return The scheduled task - */ - public static void runTask(Runnable task) { - if (instance.isPaper) { - instance.plugin.getServer().getGlobalRegionScheduler().run(instance.plugin, (plugin) -> task.run()); - } else { - instance.plugin.getServer().getScheduler().runTask(instance.plugin, task); - } - } - - /** - * Run a task repeatedly - * - * @param task The task to run - * @param delay The delay in ticks (20 ticks = 1 second) - * @param period The period in ticks (20 ticks = 1 second) - * @return The scheduled task - */ - public static void runTaskRepeat(Runnable task, long delay, long period) { - if (instance.isPaper) { - instance.plugin.getServer().getGlobalRegionScheduler().runAtFixedRate(instance.plugin, (plugin) -> task.run(), delay, period); - } else { - instance.plugin.getServer().getScheduler().runTaskTimer(instance.plugin, task, delay, period); - } - } - - /** - * Run a task later asynchronously - * - * @param task The task to run - * @param delay The delay in milliseconds - * @return The scheduled task - */ - public static void runTaskLaterAsync(Runnable task, long delay) { - if (delay <= 0) { - runTaskAsync(task); - return; - } - if (instance.isPaper) { - instance.plugin.getServer().getAsyncScheduler().runDelayed(instance.plugin, (plugin) -> task.run(), delay * 50, TimeUnit.MILLISECONDS); - } else { - instance.plugin.getServer().getScheduler().runTaskLaterAsynchronously(instance.plugin, task, delay); - } - } - /** * Run a task asynchronously * @@ -104,23 +36,7 @@ public class Scheduler { if (instance.isPaper) { instance.plugin.getServer().getAsyncScheduler().runNow(instance.plugin, (plugin) -> task.run()); } else { - instance.plugin.getServer().getScheduler().runTaskAsynchronously(instance.plugin, task); - } - } - - /** - * Run a task repeatedly asynchronously - * - * @param task The task to run - * @param delay The delay in milliseconds - * @param period The period in milliseconds - * @return The scheduled task - */ - public static void runTaskRepeatAsync(Runnable task, long delay, long period) { - if (instance.isPaper) { - instance.plugin.getServer().getAsyncScheduler().runAtFixedRate(instance.plugin, (plugin) -> task.run(), delay * 50, period * 50, TimeUnit.MILLISECONDS); - } else { - instance.plugin.getServer().getScheduler().runTaskTimerAsynchronously(instance.plugin, task, delay, period); + instance.plugin.getServer().getScheduler().runTask(instance.plugin, task); } } }