From 2829baf5b08b427c6132b807ac1207e05cd92bd2 Mon Sep 17 00:00:00 2001 From: Will FP Date: Fri, 22 Mar 2024 19:00:57 +0000 Subject: [PATCH] Preliminary support for new NMS versioning --- .../willfp/eco/core/proxy/ProxyConstants.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/eco-api/src/main/java/com/willfp/eco/core/proxy/ProxyConstants.java b/eco-api/src/main/java/com/willfp/eco/core/proxy/ProxyConstants.java index 05079b896..a2f17cc14 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/proxy/ProxyConstants.java +++ b/eco-api/src/main/java/com/willfp/eco/core/proxy/ProxyConstants.java @@ -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; @@ -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. @@ -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; + } }