修复spigot无法生成地图画的问题

This commit is contained in:
zhangyuheng 2024-07-30 16:08:40 +08:00
parent ecabf4a8bc
commit 71bf3ed675
2 changed files with 2 additions and 86 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId> <groupId>cn.lunadeer</groupId>
<artifactId>ColorfulMap</artifactId> <artifactId>ColorfulMap</artifactId>
<version>2.0</version> <version>2.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ColorfulMap</name> <name>ColorfulMap</name>

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 * Run a task asynchronously
* *
@ -104,23 +36,7 @@ public class Scheduler {
if (instance.isPaper) { if (instance.isPaper) {
instance.plugin.getServer().getAsyncScheduler().runNow(instance.plugin, (plugin) -> task.run()); instance.plugin.getServer().getAsyncScheduler().runNow(instance.plugin, (plugin) -> task.run());
} else { } else {
instance.plugin.getServer().getScheduler().runTaskAsynchronously(instance.plugin, task); instance.plugin.getServer().getScheduler().runTask(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);
} }
} }
} }