9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-19 15:09:25 +00:00

fix versionhelper

This commit is contained in:
XiaoMoMi
2025-10-14 00:36:35 +08:00
parent f991086da3
commit 2d9b9b8e31
3 changed files with 40 additions and 12 deletions

View File

@@ -58,17 +58,44 @@ public class VersionHelper {
return updateFuture;
};
private static float version;
private static int version;
private static boolean mojmap;
private static boolean folia;
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();
}
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;
}
private static void checkMojMap() {
// Check if the server is Mojmap
try {
@@ -87,31 +114,31 @@ public class VersionHelper {
}
public static boolean isVersionNewerThan1_18() {
return version >= 18f;
return version >= 11800;
}
public static boolean isVersionNewerThan1_19() {
return version >= 19f;
return version >= 11900;
}
public static boolean isVersionNewerThan1_19_4() {
return version >= 19.39f;
return version >= 11904;
}
public static boolean isVersionNewerThan1_20() {
return version >= 20f;
return version >= 12000;
}
public static boolean isVersionNewerThan1_21_4() {
return version >= 21.39f;
return version >= 12104;
}
public static boolean isVersionNewerThan1_21_2() {
return version >= 21.19f;
return version >= 12102;
}
public static boolean isVersionNewerThan1_21() {
return version >= 21f;
return version >= 12100;
}
public static boolean isFolia() {

View File

@@ -16,6 +16,7 @@ import net.momirealms.customcrops.api.core.AbstractCustomEventListener;
import net.momirealms.customcrops.api.core.AbstractItemManager;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import java.util.HashSet;
import java.util.List;
@@ -86,7 +87,7 @@ public class NexoListener extends AbstractCustomEventListener {
);
}
@EventHandler(ignoreCancelled = true)
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBreakFurniture(NexoFurnitureBreakEvent event) {
itemManager.handlePlayerBreak(
event.getPlayer(),

View File

@@ -1,6 +1,6 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=3.6.45
project_version=3.6.45.1
config_version=43
project_group=net.momirealms