9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00
This commit is contained in:
XiaoMoMi
2025-10-14 00:43:57 +08:00
parent 8a4b0e1c23
commit d9ee1bbb21
6 changed files with 85 additions and 70 deletions

View File

@@ -61,7 +61,7 @@ public class VersionHelper {
return updateFuture; return updateFuture;
}; };
private static float version; private static int version;
private static boolean mojmap; private static boolean mojmap;
private static boolean folia; private static boolean folia;
private static boolean mohist; private static boolean mohist;
@@ -74,8 +74,7 @@ public class VersionHelper {
* @param serverVersion The server version string. * @param serverVersion The server version string.
*/ */
public static void init(String serverVersion) { public static void init(String serverVersion) {
String[] split = serverVersion.split("\\."); version = parseVersionToInteger(serverVersion);
version = Float.parseFloat(split[1] + "." + (split.length == 3 ? split[2] : "0"));
checkMojMap(); checkMojMap();
checkFolia(); checkFolia();
checkMohist(); checkMohist();
@@ -84,6 +83,34 @@ public class VersionHelper {
paper = paper && !isModdedServer; 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. * 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 * Checks if the server version is newer than 1.21.5
* *
* @return True if the version is newer than 1.21.5, otherwise false. * @return True if the version is newer than 1.21.5, otherwise false.
*/ */
public static boolean isVersionNewerThan1_21_5() { 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. * @return True if the version is newer than 1.21.4, otherwise false.
*/ */
public static boolean isVersionNewerThan1_21_4() { 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. * @return True if the version is newer than 1.21.2, otherwise false.
*/ */
public static boolean isVersionNewerThan1_21_2() { 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. * @return True if the version is newer than 1.20.5, otherwise false.
*/ */
public static boolean isVersionNewerThan1_20_5() { 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. * @return True if the version is newer than 1.20.4, otherwise false.
*/ */
public static boolean isVersionNewerThan1_20_4() { 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. * @return True if the version is newer than 1.19.4, otherwise false.
*/ */
public static boolean isVersionNewerThan1_19_4() { 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. * @return True if the version is newer than 1.20.2, otherwise false.
*/ */
public static boolean isVersionNewerThan1_20_2() { 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. * @return True if the version is newer than 1.20, otherwise false.
*/ */
public static boolean isVersionNewerThan1_20() { public static boolean isVersionNewerThan1_20() {
return version >= 20f; return version >= 12000;
} }
/** /**

View File

@@ -1,9 +1,6 @@
import org.gradle.process.internal.ExecException
import java.io.ByteArrayOutputStream
plugins { plugins {
id("java") id("java")
id("com.gradleup.shadow") version "9.0.0-beta11" id("com.gradleup.shadow") version "9.2.2"
} }
val git : String = versionBanner() val git : String = versionBanner()
@@ -28,35 +25,17 @@ subprojects {
filesMatching(arrayListOf("*.yml", "*/*.yml", "META-INF/sponge_plugins.json")) { filesMatching(arrayListOf("*.yml", "*/*.yml", "META-INF/sponge_plugins.json")) {
expand( expand(
Pair("project_version", rootProject.properties["project_version"]), Pair("project_version", rootProject.properties["project_version"]!!),
Pair("config_version", rootProject.properties["config_version"]) Pair("config_version", rootProject.properties["config_version"]!!)
) )
} }
} }
} }
fun versionBanner(): String { fun versionBanner() = project.providers.exec {
val os = ByteArrayOutputStream() commandLine("git", "rev-parse", "--short=8", "HEAD")
try { }.standardOutput.asText.map { it.trim() }.getOrElse("Unknown")
project.exec {
commandLine = "git rev-parse --short=8 HEAD".split(" ")
standardOutput = os
}
} catch (e: ExecException) {
return "Unknown"
}
return String(os.toByteArray()).trim()
}
fun builder(): String { fun builder() = project.providers.exec {
val os = ByteArrayOutputStream() commandLine("git", "config", "user.name")
try { }.standardOutput.asText.map { it.trim() }.getOrElse("Unknown")
project.exec {
commandLine = "git config user.name".split(" ")
standardOutput = os
}
} catch (e: ExecException) {
return "Unknown"
}
return String(os.toByteArray()).trim()
}

View File

@@ -1,6 +1,6 @@
# Project settings # Project settings
# Rule: [major update].[feature update].[bug fix] # Rule: [major update].[feature update].[bug fix]
project_version=3.0.32 project_version=3.0.33
config_version=38 config_version=38
project_group=net.momirealms project_group=net.momirealms
@@ -11,40 +11,40 @@ lang=en,zh_cn
paper_version=1.20.4 paper_version=1.20.4
jetbrains_annotations_version=26.0.2 jetbrains_annotations_version=26.0.2
slf4j_version=2.0.17 slf4j_version=2.0.17
log4j_version=2.24.3 log4j_version=2.25.2
gson_version=2.11.0 gson_version=2.13.2
asm_version=9.8 asm_version=9.9
asm_commons_version=9.8 asm_commons_version=9.9
jar_relocator_version=1.7 jar_relocator_version=1.7
h2_driver_version=2.3.232 h2_driver_version=2.4.240
sqlite_driver_version=3.49.1.0 sqlite_driver_version=3.50.3.0
adventure_bundle_version=4.23.0 adventure_bundle_version=4.25.0
adventure_platform_version=4.4.0 adventure_platform_version=4.4.1
cloud_core_version=2.0.0 cloud_core_version=2.0.0
cloud_services_version=2.0.0 cloud_services_version=2.0.0
cloud_brigadier_version=2.0.0-beta.11 cloud_brigadier_version=2.0.0-beta.13
cloud_bukkit_version=2.0.0-beta.11 cloud_bukkit_version=2.0.0-beta.13
cloud_paper_version=2.0.0-beta.11 cloud_paper_version=2.0.0-beta.13
cloud_minecraft_extras_version=2.0.0-beta.11 cloud_minecraft_extras_version=2.0.0-beta.13
boosted_yaml_version=1.3.7 boosted_yaml_version=1.3.7
byte_buddy_version=1.17.5 byte_buddy_version=1.17.8
mojang_brigadier_version=1.0.18 mojang_brigadier_version=1.0.18
mongodb_driver_version=5.4.0 mongodb_driver_version=5.6.1
mariadb_driver_version=3.5.3 mariadb_driver_version=3.5.6
mysql_driver_version=9.2.0 mysql_driver_version=9.4.0
hikari_version=5.1.0 hikari_version=7.0.2
commons_pool_version=2.12.1 commons_pool_version=2.12.1
bstats_version=3.1.0 bstats_version=3.1.0
geantyref_version=1.3.16 geantyref_version=1.3.16
caffeine_version=3.2.0 caffeine_version=3.2.2
jedis_version=5.2.0 jedis_version=7.0.0
exp4j_version=0.4.8 exp4j_version=0.4.8
placeholder_api_version=2.11.6 placeholder_api_version=2.11.6
vault_version=1.7 vault_version=1.7
guava_version=33.4.8-jre guava_version=33.5.0-jre
commons_io_version=2.19.0 commons_io_version=2.20.0
lwjgl_version=3.3.4 lwjgl_version=3.3.6
fastutil_version=8.5.15 fastutil_version=8.5.18
# Proxy settings # Proxy settings
#systemProp.socks.proxyHost=127.0.0.1 #systemProp.socks.proxyHost=127.0.0.1

View File

@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -89,7 +89,8 @@ public class EntityDataValue {
if (VersionHelper.isVersionNewerThan1_21_5()) Serializers$OPTIONAL_LIVING_ENTITY_REFERENCE = initSerializersByName("OPTIONAL_LIVING_ENTITY_REFERENCE"); if (VersionHelper.isVersionNewerThan1_21_5()) Serializers$OPTIONAL_LIVING_ENTITY_REFERENCE = initSerializersByName("OPTIONAL_LIVING_ENTITY_REFERENCE");
else Serializers$OPTIONAL_LIVING_ENTITY_REFERENCE = null; else Serializers$OPTIONAL_LIVING_ENTITY_REFERENCE = null;
Serializers$OPTIONAL_GLOBAL_POS = initSerializersByName("OPTIONAL_GLOBAL_POS"); 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$VILLAGER_DATA = initSerializersByName("VILLAGER_DATA");
Serializers$OPTIONAL_UNSIGNED_INT = initSerializersByName("OPTIONAL_UNSIGNED_INT"); Serializers$OPTIONAL_UNSIGNED_INT = initSerializersByName("OPTIONAL_UNSIGNED_INT");
Serializers$POSE = initSerializersByName("POSE"); Serializers$POSE = initSerializersByName("POSE");

View File

@@ -28,7 +28,7 @@ import java.util.*;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
public class Reflections { public final class Reflections {
public static void load() {} public static void load() {}