Skip to content

Commit

Permalink
Preliminary support for new NMS versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Mar 22, 2024
1 parent 446e7a9 commit 2829baf
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.willfp.eco.core.proxy;

import com.willfp.eco.core.version.Version;
import org.bukkit.Bukkit;

import java.util.Arrays;
Expand All @@ -12,7 +13,7 @@ public final class ProxyConstants {
/**
* The NMS version that the server is running on.
*/
public static final String NMS_VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
public static final String NMS_VERSION;

/**
* All supported NMS versions.
Expand All @@ -32,4 +33,17 @@ public final class ProxyConstants {
private ProxyConstants() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}

static {
String currentMinecraftVersion = Bukkit.getServer().getBukkitVersion().split("-")[0];
String nmsVersion;

if (new Version(currentMinecraftVersion).compareTo(new Version("1.20.5")) < 0) {
nmsVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
} else {
nmsVersion = currentMinecraftVersion.replace(".", "_");
}

NMS_VERSION = nmsVersion;
}
}

0 comments on commit 2829baf

Please sign in to comment.