修复spigot无法生成地图画的问题
All checks were successful
Java CI-CD with Maven / build (push) Successful in 6m51s

This commit is contained in:
zhangyuheng 2024-07-30 16:11:02 +08:00
parent b8a3dbddd5
commit 67b39b6ae2

View File

@ -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
*