diff --git a/build.gradle b/build.gradle index af54d66..250c6af 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'dev.codedred' -version = '1.6.2' +version = '1.6.2b' repositories { mavenLocal() diff --git a/release.sh b/release.sh index 8754c57..3af2e6c 100644 --- a/release.sh +++ b/release.sh @@ -1,6 +1,6 @@ #!/bin/bash -NEW_VERSION="1.6.2" +NEW_VERSION="1.6.2b" git checkout main git pull origin main diff --git a/src/main/java/me/codedred/playtimes/utils/ServerUtils.java b/src/main/java/me/codedred/playtimes/utils/ServerUtils.java index a6d4e07..271151f 100644 --- a/src/main/java/me/codedred/playtimes/utils/ServerUtils.java +++ b/src/main/java/me/codedred/playtimes/utils/ServerUtils.java @@ -36,16 +36,36 @@ public static boolean isNewerVersion() { * @return true if so */ public static boolean isRisenVersion() { - String[] versionParts = Bukkit.getServer().getVersion().split("\\."); + String version = Bukkit.getServer().getVersion(); + String mcVersion = null; - int majorVersion = Integer.parseInt( - versionParts[1].replaceAll("[^0-9]", "") - ); - int minorVersion = 0; - if (versionParts.length >= 3) minorVersion = - Integer.parseInt(versionParts[2].replaceAll("[^0-9]", "")); + if (version.contains("(MC:")) { + int startIndex = version.indexOf("(MC:") + 5; + int endIndex = version.indexOf(")", startIndex); + mcVersion = version.substring(startIndex, endIndex).trim(); + } + + if (mcVersion == null) { + Bukkit + .getLogger() + .warning("PlayTimes failed to extract Minecraft version: " + version); + return false; + } - return majorVersion >= 17 && minorVersion >= 0; + String[] versionParts = mcVersion.split("\\."); + + try { + int minorVersion = versionParts.length >= 2 + ? Integer.parseInt(versionParts[1]) + : 0; + + return minorVersion >= 17; + } catch (NumberFormatException e) { + Bukkit + .getLogger() + .warning("PlayTimes failed to parse Minecraft version: " + mcVersion); + return false; + } } public static boolean hasPAPI() { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 12910ec..28e9e86 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,6 @@ name: Playtimes version: "${version}" main: me.codedred.playtimes.PlayTimes -api-version: 1.19 author: Cmaaxx authors: [CodedRed] softdepend: [PlaceholderAPI]