Merge pull request #197 from dniym/fix/1.21-support
1.21 support & Bug Fixes
This commit is contained in:
3 files changed
+29
-5
No files matched your search
+1
-1
@@ -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")
|
||||
|
||||
@@ -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 class IllegalStack extends JavaPlugin {
|
||||
return Spigot;
|
||||
}
|
||||
|
||||
public static boolean isFoliaServer() {
|
||||
return isFoliaServer;
|
||||
}
|
||||
|
||||
public static boolean isCMI() {
|
||||
return CMI;
|
||||
}
|
||||
@@ -164,10 +169,22 @@ public class IllegalStack extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
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 class IllegalStack extends JavaPlugin {
|
||||
loadMsgs();
|
||||
checkForHybridEnvironment();
|
||||
checkForPaperServer();
|
||||
checkForFoliaServer();
|
||||
IllegalStackCommand illegalStackCommand = new IllegalStackCommand();
|
||||
this.getCommand("istack").setExecutor(illegalStackCommand);
|
||||
this.getCommand("istack").setTabCompleter(illegalStackCommand);
|
||||
@@ -1018,7 +1036,7 @@ public class IllegalStack extends JavaPlugin {
|
||||
disable = true;
|
||||
if (hasAsyncScheduler) {
|
||||
getServer().getAsyncScheduler().cancelTasks(this);
|
||||
} else {
|
||||
} else if (!isFoliaServer()){
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
@@ -1119,8 +1137,12 @@ public class IllegalStack extends JavaPlugin {
|
||||
} 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.", ""));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user