From ded73b5057fbb15f04d0acaee7b441bf263ccbdd Mon Sep 17 00:00:00 2001 From: ItsFlicker <1812496278@qq.com> Date: Sun, 22 Sep 2024 15:47:56 +0800 Subject: [PATCH] [2.2.0-beta4] Fix --- build.gradle.kts | 31 ++++++------------- gradle.properties | 2 +- .../arasple/mc/trchat/api/nms/NMSImpl12100.kt | 14 ++++++--- .../display/function/standard/ItemShow.kt | 2 +- .../mc/trchat/module/internal/TrChatBukkit.kt | 12 +++---- .../internal/listener/ListenerPackets.kt | 2 ++ .../arasple/mc/trchat/util/ComponentUtil.kt | 3 +- 7 files changed, 28 insertions(+), 38 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 50dc8246..35a46e41 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,9 @@ -import io.izzel.taboolib.gradle.BUKKIT -import io.izzel.taboolib.gradle.BUNGEE -import io.izzel.taboolib.gradle.VELOCITY +import io.izzel.taboolib.gradle.* import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { java - id("io.izzel.taboolib") version "2.0.13" + id("io.izzel.taboolib") version "2.0.18" id("org.jetbrains.kotlin.jvm") version "1.8.22" } @@ -18,13 +16,10 @@ subprojects { env { install("basic-configuration") install( - "bukkit-hook", - "bukkit-util", - "bukkit-ui", - "bukkit-ui-12100", - "bukkit-ui-legacy", - "bukkit-xseries", - "bukkit-xseries-item" + BukkitHook, + BukkitNMSUtil, + BukkitNMSItemTag, + BukkitUI ) install( "database", @@ -38,19 +33,11 @@ subprojects { "minecraft-kether", "minecraft-metrics" ) - install( - "bukkit-nms", - "bukkit-nms-stable", - "bukkit-nms-tag", - "bukkit-nms-tag-12005", - "bukkit-nms-tag-legacy", - ) - install("script-javascript") - install(BUKKIT, BUNGEE, VELOCITY) - install("platform-bukkit-impl") + install(JavaScript) + install(Bukkit, BungeeCord, Velocity) } version { - taboolib = "6.2.0-beta5" + taboolib = "6.2.0-beta11" coroutines = null // isSkipKotlin = true // isSkipKotlinRelocate = true diff --git a/gradle.properties b/gradle.properties index ba1c68cd..e39d8ade 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.arasple.mc.trchat -version=2.2.0-beta3 +version=2.2.0-beta4 kotlin.incremental=true kotlin.incremental.java=true kotlin.incremental.useClasspathSnapshot=true diff --git a/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl12100.kt b/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl12100.kt index eb780a25..d8b36161 100644 --- a/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl12100.kt +++ b/project/module-nms/src/main/kotlin/me/arasple/mc/trchat/api/nms/NMSImpl12100.kt @@ -1,20 +1,24 @@ package me.arasple.mc.trchat.api.nms +import net.minecraft.network.chat.IChatBaseComponent +import org.bukkit.craftbukkit.v1_20_R3.util.CraftChatMessage import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import taboolib.common.platform.function.adaptPlayer import taboolib.module.chat.ComponentText import taboolib.module.nms.MinecraftLanguage +import taboolib.module.nms.getLanguageKey +import taboolib.platform.util.hoverItem import java.util.* class NMSImpl12100 : NMS() { override fun craftChatMessageFromComponent(component: ComponentText): Any { - TODO("Not yet implemented") + return CraftChatMessage.fromJSON(component.toRawMessage()) } override fun rawMessageFromCraftChatMessage(component: Any): String { - TODO("Not yet implemented") + return CraftChatMessage.toJSON(component as IChatBaseComponent) } override fun sendMessage(receiver: Player, component: ComponentText, sender: UUID?, usePacket: Boolean) { @@ -22,14 +26,14 @@ class NMSImpl12100 : NMS() { } override fun hoverItem(component: ComponentText, itemStack: ItemStack): ComponentText { - TODO("Not yet implemented") + return component.hoverItem(itemStack) } override fun optimizeNBT(itemStack: ItemStack, nbtWhitelist: Array): ItemStack { - TODO("Not yet implemented") + return itemStack } override fun getLocaleKey(itemStack: ItemStack): MinecraftLanguage.LanguageKey { - TODO("Not yet implemented") + return itemStack.getLanguageKey() } } \ No newline at end of file diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt index c0f511e2..d6bc1cd0 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/display/function/standard/ItemShow.kt @@ -216,7 +216,7 @@ object ItemShow : Function("ITEM") { Components.text(itemMeta!!.displayName) } } - } else if (Folia.isFolia || MinecraftVersion.majorLegacy >= 12005) { + } else if (Folia.isFolia) { toTranslatableComponentAdventure() } else { try { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt index c57721ea..224f1f7c 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/TrChatBukkit.kt @@ -18,8 +18,6 @@ import taboolib.common.platform.function.console import taboolib.common.platform.function.pluginVersion import taboolib.module.lang.sendLang import taboolib.module.nms.MinecraftVersion.majorLegacy -import taboolib.module.nms.disablePacketListener -import taboolib.platform.Folia @PlatformSide(Platform.BUKKIT) object TrChatBukkit : Plugin() { @@ -53,11 +51,11 @@ object TrChatBukkit : Plugin() { } override fun onEnable() { - if (!Settings.usePackets - || Folia.isFolia - || Bukkit.getPluginManager().isPluginEnabled("Geyser-Spigot") - || majorLegacy >= 12005 - ) disablePacketListener() +// if (!Settings.usePackets +// || Folia.isFolia +// || Bukkit.getPluginManager().isPluginEnabled("Geyser-Spigot") +// || majorLegacy >= 12005 +// ) disablePacketListener() NMS.instance BukkitProxyManager.processor HookPlugin.printInfo() diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt index cef429c8..10490f80 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/module/internal/listener/ListenerPackets.kt @@ -37,6 +37,7 @@ object ListenerPackets { @SubscribeEvent fun secure(e: PacketReceiveEvent) { + if (majorLegacy >= 12005) return if (e.packet.name == "ServerboundChatSessionUpdatePacket") { e.isCancelled = true } @@ -47,6 +48,7 @@ object ListenerPackets { */ @SubscribeEvent fun record(e: PacketSendEvent) { + if (majorLegacy >= 12005) return val session = ChatSession.sessions[e.player.uniqueId] ?: return when (e.packet.name) { "ClientboundSystemChatPacket" -> { diff --git a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt index dbadd26a..81625864 100644 --- a/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt +++ b/project/runtime-bukkit/src/main/kotlin/me/arasple/mc/trchat/util/ComponentUtil.kt @@ -11,7 +11,6 @@ import org.bukkit.inventory.meta.BlockStateMeta import org.bukkit.inventory.meta.ItemMeta import taboolib.module.chat.ComponentText import taboolib.module.chat.component -import taboolib.module.nms.MinecraftVersion import taboolib.module.nms.getI18nName import taboolib.platform.Folia import taboolib.platform.util.* @@ -21,7 +20,7 @@ fun String.parseSimple() = component().build { } fun ComponentText.hoverItemFixed(item: ItemStack): ComponentText { - if (Folia.isFolia || MinecraftVersion.majorLegacy >= 12005) { + if (Folia.isFolia) { return hoverItemAdventure(item) } var newItem = item.optimizeShulkerBox()