diff --git a/build.gradle.kts b/build.gradle.kts index d8a632a..b77fa28 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,7 +39,7 @@ repositories { } dependencies { - compileOnly("dev.folia:folia-api:1.20.2-R0.1-SNAPSHOT") + compileOnly("dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT") compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0") compileOnly("com.elmakers.mine.bukkit:MagicAPI:10.2") compileOnly("de.tr7zw:item-nbt-api-plugin:2.8.0") diff --git a/src/main/java/main/java/me/dniym/IllegalStack.java b/src/main/java/main/java/me/dniym/IllegalStack.java index baacbde..1d51ddf 100644 --- a/src/main/java/main/java/me/dniym/IllegalStack.java +++ b/src/main/java/main/java/me/dniym/IllegalStack.java @@ -45,6 +45,7 @@ public class IllegalStack extends JavaPlugin { private static Plugin ProCosmetics = null; private static boolean isHybridEnvironment = false; private static boolean isPaperServer = false; + private static boolean isFoliaServer = false; private static boolean hasProtocolLib = false; private static boolean hasAttribAPI = false; private static boolean nbtAPI = false; @@ -99,6 +100,10 @@ public static boolean isSpigot() { return Spigot; } + public static boolean isFoliaServer() { + return isFoliaServer; + } + public static boolean isCMI() { return CMI; } @@ -164,10 +169,22 @@ private static void checkForPaperServer() { } } + private static void checkForFoliaServer() { + try { + Class.forName("io.papermc.paper.threadedregions.RegionizedServer"); + isFoliaServer = true; + LOGGER.info("Server has Folia components, enabling Folia features."); + } catch (ClassNotFoundException e) { + isFoliaServer = false; + LOGGER.info("Server does NOT have Folia components, continuing as normal."); + } + } + private static void StartupPlugin() { checkForHybridEnvironment(); checkForPaperServer(); + checkForFoliaServer(); try { Class.forName("org.spigotmc.SpigotConfig"); @@ -424,6 +441,7 @@ public void onEnable() { loadMsgs(); checkForHybridEnvironment(); checkForPaperServer(); + checkForFoliaServer(); IllegalStackCommand illegalStackCommand = new IllegalStackCommand(); this.getCommand("istack").setExecutor(illegalStackCommand); this.getCommand("istack").setTabCompleter(illegalStackCommand); @@ -1018,7 +1036,7 @@ public void onDisable() { disable = true; if (hasAsyncScheduler) { getServer().getAsyncScheduler().cancelTasks(this); - } else { + } else if (!isFoliaServer()){ Bukkit.getScheduler().cancelTasks(this); } @@ -1119,8 +1137,12 @@ private void setVersion() { } else { String packageName = Bukkit.getServer().getClass().getPackage().getName(); String bukkitVersion = Bukkit.getServer().getBukkitVersion(); - if (bukkitVersion.contains("1.20.5") || bukkitVersion.contains("1.20.6")) { - serverVersion = ServerVersion.v1_20_R4; + if (bukkitVersion.contains("1.20.5")) { + serverVersion = ServerVersion.v1_20_R5; + } else if (bukkitVersion.contains("1.20.6")) { + serverVersion = ServerVersion.v1_20_R5; + } else if (bukkitVersion.contains("1.21")) { + serverVersion = ServerVersion.v1_21_R1; } else { serverVersion = ServerVersion.valueOf(packageName.replace("org.bukkit.craftbukkit.", "")); } diff --git a/src/main/java/main/java/me/dniym/enums/ServerVersion.java b/src/main/java/main/java/me/dniym/enums/ServerVersion.java index 44e2784..fb56ffd 100644 --- a/src/main/java/main/java/me/dniym/enums/ServerVersion.java +++ b/src/main/java/main/java/me/dniym/enums/ServerVersion.java @@ -26,7 +26,9 @@ public enum ServerVersion { v1_20_R1, v1_20_R2, v1_20_R3, - v1_20_R4; + v1_20_R4, + v1_20_R5, + v1_21_R1; public boolean serverVersionEqual(ServerVersion version) { return this.equals(version);