diff --git a/gradle.properties b/gradle.properties index 86b09ea1..e7080b63 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 4f23d11b..9e42f210 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 7327505a..66279b7f 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 dc3bd411..f99a90f8 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(){