Merge MoRanYue/FoliaFlow

This commit is contained in:
MidnightTale 2026-08-03 11:24:15 +07:00
commit a5172407b5

View file

@ -10,10 +10,11 @@ public class SchedulerUtil {
private static boolean tryFolia() { private static boolean tryFolia() {
try { try {
Bukkit.getAsyncScheduler(); Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
return true; return true;
} catch (Throwable ignored) {} } catch (ClassNotFoundException e) {
return false; return false;
}
} }
public static Boolean isFolia() { public static Boolean isFolia() {
@ -22,7 +23,10 @@ public class SchedulerUtil {
} }
public static void runLaterEntity(Entity entity, Plugin plugin, Runnable runnable, int ticks) { public static void runLaterEntity(Entity entity, Plugin plugin, Runnable runnable, int ticks) {
if (isFolia()) entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks); if (isFolia()) {
else Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks); entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks);
} else {
Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks);
}
} }
} }