From ceb2370cefa7f2bd044ebed8d53181fd1831c555 Mon Sep 17 00:00:00 2001 From: Penal Buffalo Date: Sun, 22 Dec 2024 09:30:21 -0600 Subject: [PATCH] v4.2.0.1 b93 * fix errors with folia when it was built with mojangmap --- gradle.properties | 2 +- .../arcaneplugins/levelledmobs/nametag/Definitions.kt | 8 ++++---- .../levelledmobs/nametag/NametagSenderHandler.kt | 5 +---- .../levelledmobs/nametag/ServerVersionInfo.kt | 11 +++++++++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 86b09ea1c..e7080b63b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version = 4.2.0 b92 +version = 4.2.0.1 b93 description = The Ultimate RPG Mob Levelling Solution org.gradle.caching=true diff --git a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/Definitions.kt b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/Definitions.kt index 4f23d11b6..9e42f2100 100644 --- a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/Definitions.kt +++ b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/Definitions.kt @@ -2,6 +2,7 @@ package io.github.arcaneplugins.levelledmobs.nametag import io.github.arcaneplugins.levelledmobs.LevelledMobs import io.github.arcaneplugins.levelledmobs.nametag.ServerVersionInfo.MinecraftMajorVersion +import io.github.arcaneplugins.levelledmobs.util.Log import java.lang.reflect.Constructor import java.lang.reflect.Field import java.lang.reflect.Method @@ -154,6 +155,8 @@ class Definitions{ fun load(){ ver = LevelledMobs.instance.ver + + Log.inf("Building reflection cache, use simple names: ${ver.useSimpleName}") build() if (hasMiniMessage) mm = MiniMessage.miniMessage() } @@ -189,10 +192,7 @@ class Definitions{ // if running folia only use simple name if the version is 1.21+ - val useSimpleName = (ver.isRunningPaper && isOneTwentyFiveOrNewer || ver.isRunningFabric) && - (!ver.isRunningFolia || ver.minorVersion >= 22) - - return if (useSimpleName) { + return if (ver.useSimpleName) { "org.bukkit.craftbukkit.$classSuffix" } else { ("org.bukkit.craftbukkit." + ver.nmsVersion) + "." + classSuffix diff --git a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/NametagSenderHandler.kt b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/NametagSenderHandler.kt index 7327505a3..66279b7ff 100644 --- a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/NametagSenderHandler.kt +++ b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/NametagSenderHandler.kt @@ -19,12 +19,9 @@ class NametagSenderHandler { } this.currentUtil = NmsNametagSender() - val ver = LevelledMobs.instance.ver - val showVersion = if (ver.isRunningPaper && "unknown" == ver.nmsVersion) - Bukkit.getServer().minecraftVersion else ver.nmsVersion Log.inf( - "Using NMS version $showVersion for nametag support" + "Using NMS version ${LevelledMobs.instance.ver.nmsVersion} for nametag support" ) return this.currentUtil diff --git a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/ServerVersionInfo.kt b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/ServerVersionInfo.kt index dc3bd411e..f99a90f82 100644 --- a/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/ServerVersionInfo.kt +++ b/levelledmobs-plugin/src/main/kotlin/io/github/arcaneplugins/levelledmobs/nametag/ServerVersionInfo.kt @@ -17,6 +17,11 @@ class ServerVersionInfo { fun load(){ parseServerVersion() parseNMSVersion() + + if (isRunningPaper && "unknown" == nmsVersion) { + nmsVersion = Bukkit.getServer().minecraftVersion + useSimpleName = true + } } var majorVersion = 0 @@ -36,6 +41,8 @@ class ServerVersionInfo { private set var allowStructureConditions = false private set + var useSimpleName = true + private set // preliminary fabric support. not entirely there yet private var _isRunningFabric: Boolean? = null @@ -64,6 +71,10 @@ class ServerVersionInfo { useOldEnums = minorVersion < 21 || minorVersion == 21 && revision < 3 useNewHorseJumpAttrib = minorVersion >= 21 || (minorVersion == 20 && revision >= 6) + + useSimpleName = (isRunningPaper && isOneTwentyFiveOrNewer && !isRunningFolia + || isRunningFabric) + && (!isRunningFolia || minorVersion >= 22) } private fun parsePaperVersion(){