Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21 support & Bug Fixes #197

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -66,7 +66,7 @@ tasks.compileJava.configure {
options.release.set(8)
}

version = "2.9.11-SNAPSHOT-01"
version = "2.9.12-SNAPSHOT-01"

tasks.named<Copy>("processResources") {
filesMatching("plugin.yml") {
Expand Down
28 changes: 25 additions & 3 deletions src/main/java/main/java/me/dniym/IllegalStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,6 +100,10 @@ public static boolean isSpigot() {
return Spigot;
}

public static boolean isFoliaServer() {
return isFoliaServer;
}

public static boolean isCMI() {
return CMI;
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1018,7 +1036,7 @@ public void onDisable() {
disable = true;
if (hasAsyncScheduler) {
getServer().getAsyncScheduler().cancelTasks(this);
} else {
} else if (!isFoliaServer()){
Bukkit.getScheduler().cancelTasks(this);
}

Expand Down Expand Up @@ -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.", ""));
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/main/java/me/dniym/enums/ServerVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading