diff --git a/api/src/main/java/net/momirealms/customnameplates/api/helper/VersionHelper.java b/api/src/main/java/net/momirealms/customnameplates/api/helper/VersionHelper.java index 37b6cac..3383cd4 100644 --- a/api/src/main/java/net/momirealms/customnameplates/api/helper/VersionHelper.java +++ b/api/src/main/java/net/momirealms/customnameplates/api/helper/VersionHelper.java @@ -61,7 +61,7 @@ public class VersionHelper { return updateFuture; }; - private static float version; + private static int version; private static boolean mojmap; private static boolean folia; private static boolean mohist; @@ -74,8 +74,7 @@ public class VersionHelper { * @param serverVersion The server version string. */ public static void init(String serverVersion) { - String[] split = serverVersion.split("\\."); - version = Float.parseFloat(split[1] + "." + (split.length == 3 ? split[2] : "0")); + version = parseVersionToInteger(serverVersion); checkMojMap(); checkFolia(); checkMohist(); @@ -84,6 +83,34 @@ public class VersionHelper { paper = paper && !isModdedServer; } + public static int parseVersionToInteger(String versionString) { + int major = 0; + int minor = 0; + int currentNumber = 0; + int part = 0; + for (int i = 0; i < versionString.length(); i++) { + char c = versionString.charAt(i); + if (c >= '0' && c <= '9') { + currentNumber = currentNumber * 10 + (c - '0'); + } else if (c == '.') { + if (part == 1) { + major = currentNumber; + } + part++; + currentNumber = 0; + if (part > 2) { + break; + } + } + } + if (part == 1) { + major = currentNumber; + } else if (part == 2) { + minor = currentNumber; + } + return 10000 + major * 100 + minor; + } + /** * Gets the current server version as a float. * @@ -137,13 +164,22 @@ public class VersionHelper { } } + /** + * Checks if the server version is newer than 1.21.9 + * + * @return True if the version is newer than 1.21.9, otherwise false. + */ + public static boolean isVersionNewerThan1_21_9() { + return version >= 12109; + } + /** * Checks if the server version is newer than 1.21.5 * * @return True if the version is newer than 1.21.5, otherwise false. */ public static boolean isVersionNewerThan1_21_5() { - return version >= 21.49f; + return version >= 12105; } /** @@ -152,7 +188,7 @@ public class VersionHelper { * @return True if the version is newer than 1.21.4, otherwise false. */ public static boolean isVersionNewerThan1_21_4() { - return version >= 21.39f; + return version >= 12104; } /** @@ -161,7 +197,7 @@ public class VersionHelper { * @return True if the version is newer than 1.21.2, otherwise false. */ public static boolean isVersionNewerThan1_21_2() { - return version >= 21.19f; + return version >= 12102; } /** @@ -170,7 +206,7 @@ public class VersionHelper { * @return True if the version is newer than 1.20.5, otherwise false. */ public static boolean isVersionNewerThan1_20_5() { - return version >= 20.49f; + return version >= 12005; } /** @@ -179,7 +215,7 @@ public class VersionHelper { * @return True if the version is newer than 1.20.4, otherwise false. */ public static boolean isVersionNewerThan1_20_4() { - return version >= 20.39f; + return version >= 12004; } /** @@ -188,7 +224,7 @@ public class VersionHelper { * @return True if the version is newer than 1.19.4, otherwise false. */ public static boolean isVersionNewerThan1_19_4() { - return version >= 19.39f; + return version >= 11904; } /** @@ -197,7 +233,7 @@ public class VersionHelper { * @return True if the version is newer than 1.20.2, otherwise false. */ public static boolean isVersionNewerThan1_20_2() { - return version >= 20.19f; + return version >= 12002; } /** @@ -206,7 +242,7 @@ public class VersionHelper { * @return True if the version is newer than 1.20, otherwise false. */ public static boolean isVersionNewerThan1_20() { - return version >= 20f; + return version >= 12000; } /** diff --git a/build.gradle.kts b/build.gradle.kts index b2d6e46..5770db2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,6 @@ -import org.gradle.process.internal.ExecException -import java.io.ByteArrayOutputStream - plugins { id("java") - id("com.gradleup.shadow") version "9.0.0-beta11" + id("com.gradleup.shadow") version "9.2.2" } val git : String = versionBanner() @@ -28,35 +25,17 @@ subprojects { filesMatching(arrayListOf("*.yml", "*/*.yml", "META-INF/sponge_plugins.json")) { expand( - Pair("project_version", rootProject.properties["project_version"]), - Pair("config_version", rootProject.properties["config_version"]) + Pair("project_version", rootProject.properties["project_version"]!!), + Pair("config_version", rootProject.properties["config_version"]!!) ) } } } -fun versionBanner(): String { - val os = ByteArrayOutputStream() - try { - project.exec { - commandLine = "git rev-parse --short=8 HEAD".split(" ") - standardOutput = os - } - } catch (e: ExecException) { - return "Unknown" - } - return String(os.toByteArray()).trim() -} +fun versionBanner() = project.providers.exec { + commandLine("git", "rev-parse", "--short=8", "HEAD") +}.standardOutput.asText.map { it.trim() }.getOrElse("Unknown") -fun builder(): String { - val os = ByteArrayOutputStream() - try { - project.exec { - commandLine = "git config user.name".split(" ") - standardOutput = os - } - } catch (e: ExecException) { - return "Unknown" - } - return String(os.toByteArray()).trim() -} \ No newline at end of file +fun builder() = project.providers.exec { + commandLine("git", "config", "user.name") +}.standardOutput.asText.map { it.trim() }.getOrElse("Unknown") \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1feb30a..396ce83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Project settings # Rule: [major update].[feature update].[bug fix] -project_version=3.0.32 +project_version=3.0.33 config_version=38 project_group=net.momirealms @@ -11,40 +11,40 @@ lang=en,zh_cn paper_version=1.20.4 jetbrains_annotations_version=26.0.2 slf4j_version=2.0.17 -log4j_version=2.24.3 -gson_version=2.11.0 -asm_version=9.8 -asm_commons_version=9.8 +log4j_version=2.25.2 +gson_version=2.13.2 +asm_version=9.9 +asm_commons_version=9.9 jar_relocator_version=1.7 -h2_driver_version=2.3.232 -sqlite_driver_version=3.49.1.0 -adventure_bundle_version=4.23.0 -adventure_platform_version=4.4.0 +h2_driver_version=2.4.240 +sqlite_driver_version=3.50.3.0 +adventure_bundle_version=4.25.0 +adventure_platform_version=4.4.1 cloud_core_version=2.0.0 cloud_services_version=2.0.0 -cloud_brigadier_version=2.0.0-beta.11 -cloud_bukkit_version=2.0.0-beta.11 -cloud_paper_version=2.0.0-beta.11 -cloud_minecraft_extras_version=2.0.0-beta.11 +cloud_brigadier_version=2.0.0-beta.13 +cloud_bukkit_version=2.0.0-beta.13 +cloud_paper_version=2.0.0-beta.13 +cloud_minecraft_extras_version=2.0.0-beta.13 boosted_yaml_version=1.3.7 -byte_buddy_version=1.17.5 +byte_buddy_version=1.17.8 mojang_brigadier_version=1.0.18 -mongodb_driver_version=5.4.0 -mariadb_driver_version=3.5.3 -mysql_driver_version=9.2.0 -hikari_version=5.1.0 +mongodb_driver_version=5.6.1 +mariadb_driver_version=3.5.6 +mysql_driver_version=9.4.0 +hikari_version=7.0.2 commons_pool_version=2.12.1 bstats_version=3.1.0 geantyref_version=1.3.16 -caffeine_version=3.2.0 -jedis_version=5.2.0 +caffeine_version=3.2.2 +jedis_version=7.0.0 exp4j_version=0.4.8 placeholder_api_version=2.11.6 vault_version=1.7 -guava_version=33.4.8-jre -commons_io_version=2.19.0 -lwjgl_version=3.3.4 -fastutil_version=8.5.15 +guava_version=33.5.0-jre +commons_io_version=2.20.0 +lwjgl_version=3.3.6 +fastutil_version=8.5.18 # Proxy settings #systemProp.socks.proxyHost=127.0.0.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f584c8c..8adca26 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists - +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/EntityDataValue.java b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/EntityDataValue.java index 8285e50..7293aff 100644 --- a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/EntityDataValue.java +++ b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/EntityDataValue.java @@ -89,7 +89,8 @@ public class EntityDataValue { if (VersionHelper.isVersionNewerThan1_21_5()) Serializers$OPTIONAL_LIVING_ENTITY_REFERENCE = initSerializersByName("OPTIONAL_LIVING_ENTITY_REFERENCE"); else Serializers$OPTIONAL_LIVING_ENTITY_REFERENCE = null; Serializers$OPTIONAL_GLOBAL_POS = initSerializersByName("OPTIONAL_GLOBAL_POS"); - Serializers$COMPOUND_TAG = initSerializersByName("COMPOUND_TAG"); + if (!VersionHelper.isVersionNewerThan1_21_9()) Serializers$COMPOUND_TAG = initSerializersByName("COMPOUND_TAG"); + else Serializers$COMPOUND_TAG = null; Serializers$VILLAGER_DATA = initSerializersByName("VILLAGER_DATA"); Serializers$OPTIONAL_UNSIGNED_INT = initSerializersByName("OPTIONAL_UNSIGNED_INT"); Serializers$POSE = initSerializersByName("POSE"); diff --git a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java index e56bd76..667cbd8 100644 --- a/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java +++ b/platforms/bukkit/src/main/java/net/momirealms/customnameplates/bukkit/util/Reflections.java @@ -28,7 +28,7 @@ import java.util.*; import static java.util.Objects.requireNonNull; -public class Reflections { +public final class Reflections { public static void load() {}