fuck, wrong upload
This commit is contained in:
parent
54521db2a3
commit
e1992ec5b7
1 changed files with 0 additions and 30 deletions
|
|
@ -1,30 +0,0 @@
|
||||||
package one.eim.gravitycontrol;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class Compatibility {
|
|
||||||
|
|
||||||
public static Boolean IS_FOLIA = null;
|
|
||||||
|
|
||||||
private static boolean methodExist(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
|
|
||||||
try {
|
|
||||||
clazz.getDeclaredMethod(methodName, parameterTypes);
|
|
||||||
return true;
|
|
||||||
} catch (Throwable ignored) {}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean isFolia() {
|
|
||||||
if (IS_FOLIA == null) IS_FOLIA = methodExist(Bukkit.class, "getGlobalRegionScheduler");
|
|
||||||
return IS_FOLIA;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void runTaskAsync(Plugin plugin, Runnable runnable) {
|
|
||||||
if (isFolia()) {
|
|
||||||
Bukkit.getAsyncScheduler().runNow(plugin, (task) -> runnable.run());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue