Merge branch 'master' into develop

This commit is contained in:
Maxlego08 2024-06-24 09:42:32 +02:00
commit 3aa2831ffe
3 changed files with 35 additions and 23 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.maxlego08.koth</groupId>
<artifactId>zKoth</artifactId>
<version>3.0.7</version>
<version>3.0.8</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.maxlego08.koth</groupId>
<artifactId>zKoth</artifactId>
<version>3.0.7</version>
<version>3.0.8</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>

View File

@ -1,6 +1,7 @@
package fr.maxlego08.koth.zcore.utils.nms;
import org.bukkit.Bukkit;
import fr.maxlego08.koth.zcore.logger.Logger;
public class NMSUtils {
@ -11,23 +12,34 @@ public class NMSUtils {
}
/**
* Get minecraft serveur version
*
* Get minecraft server version
*
* @return version
*/
public static double getNMSVersion() {
if (version != 0)
return version;
String var1 = Bukkit.getServer().getClass().getPackage().getName();
String[] arrayOfString = var1.replace(".", ",").split(",")[3].split("_");
String var2 = arrayOfString[0].replace("v", "");
String var3 = arrayOfString[1];
return version = Double.parseDouble(var2 + "." + var3);
String[] arrayOfString = var1.replace(".", ",").split(",");
if (arrayOfString.length > 3) {
String[] versionParts = arrayOfString[3].split("_");
if (versionParts.length >= 2) {
String var2 = versionParts[0].replace("v", "");
String var3 = versionParts[1];
return version = Double.parseDouble(var2 + "." + var3);
} else {
Logger.info("Unexpected NMS version format: " + var1);
return version = 0; // default to 0 if the format is unexpected
}
} else {
Logger.info("Unexpected NMS version format: " + var1);
return version = 0; // default to 0 if the format is unexpected
}
}
/**
* Check if minecraft version has shulker
*
*
* @return boolean
*/
public static boolean hasShulker() {
@ -36,8 +48,8 @@ public class NMSUtils {
/**
* Check if minecraft version has barrel
*
* @return booleab
*
* @return boolean
*/
public static boolean hasBarrel() {
final double version = getNMSVersion();
@ -46,8 +58,8 @@ public class NMSUtils {
}
/**
* check if version is granther than 1.13
*
* Check if version is greater than 1.13
*
* @return boolean
*/
public static boolean isNewVersion() {
@ -56,7 +68,7 @@ public class NMSUtils {
/**
* Check if version has one hand
*
*
* @return boolean
*/
public static boolean isOneHand() {
@ -65,7 +77,7 @@ public class NMSUtils {
/**
* Check is version is minecraft 1.7
*
*
* @return boolean
*/
public static boolean isVeryOldVersion() {
@ -74,7 +86,7 @@ public class NMSUtils {
/**
* Check if version has itemmeta unbreakable
*
*
* @return boolean
*/
public static boolean isUnbreakable() {
@ -83,7 +95,7 @@ public class NMSUtils {
/**
* Check if version is old version of minecraft with old material system
*
*
* @return boolean
*/
public static boolean isOldVersion() {
@ -92,9 +104,9 @@ public class NMSUtils {
}
/**
*
* Check if server vesion is new version
*
*
* Check if server version is new version
*
* @return boolean
*/
public static boolean isNewNMSVersion() {
@ -104,9 +116,9 @@ public class NMSUtils {
}
/**
*
*
* Check if server version is new version
*
*
* @return boolean
*/
public static boolean isNewNBTVersion() {
@ -118,7 +130,7 @@ public class NMSUtils {
/**
* Allows to check if the version has the colors in hex
*
*
* @return boolean
*/
public static boolean isHexColor() {