From 2b4739e080d2c5eb393b4595808dde01abcc2ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=98=BF=E9=B9=B0?= Date: Sun, 26 Oct 2025 17:32:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(item):=20=E8=B0=83=E6=95=B4NBT=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E8=A7=A3=E6=9E=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改JSON解析条件判断顺序,优先检查JSON格式 - 确保在处理NBT数据前验证插件是否已加载 - 避免因插件未加载导致的线程卡死 --- plugin/src/main/kotlin/trplugins/menu/util/bukkit/ItemHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/kotlin/trplugins/menu/util/bukkit/ItemHelper.kt b/plugin/src/main/kotlin/trplugins/menu/util/bukkit/ItemHelper.kt index 51159712..93fed24a 100644 --- a/plugin/src/main/kotlin/trplugins/menu/util/bukkit/ItemHelper.kt +++ b/plugin/src/main/kotlin/trplugins/menu/util/bukkit/ItemHelper.kt @@ -92,7 +92,7 @@ object ItemHelper { fun fromJson(json: String): ItemStack? { try { // 自动判别老式/新式 NBT 标签 - if (HookPlugin.getNBTAPI().isHooked && json.startsWith("{\"item\":")) { + if (json.startsWith("{\"item\":") && HookPlugin.getNBTAPI().isHooked) { return HookPlugin.getNBTAPI().fromJson(json) } val parse = JsonParser().parse(json) From 3eb1984279eeaad5efb18e23f66655257191fdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=98=BF=E9=B9=B0?= Date: Mon, 27 Oct 2025 17:04:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore(plugin):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A2=91=E7=B9=81=E8=B0=83=E7=94=A8=20inventory.holder=20?= =?UTF-8?q?=E5=8D=A1=E6=9C=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将插件版本从3.8.7 升级至 3.8.8 - 移除废弃的 InventoryNMSImpl 和 InventoryNMS 类 - 在 Shortcuts 中增加对 PlayerInventory 的判断以避免非玩家背包点击事件处理 - 为 WindowListener 增加静态菜单类型检查,防止非法操作触发卡服 --- .../vanilla/window/WindowListener.kt | 4 ++++ gradle.properties | 2 +- .../internal/listener/ListenerItemInteract.kt | 19 ------------------- .../menu/module/internal/service/Shortcuts.kt | 3 +++ 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/api/receptacle/src/main/kotlin/trplugins/menu/api/receptacle/vanilla/window/WindowListener.kt b/api/receptacle/src/main/kotlin/trplugins/menu/api/receptacle/vanilla/window/WindowListener.kt index ff793a3a..c11dbc6f 100644 --- a/api/receptacle/src/main/kotlin/trplugins/menu/api/receptacle/vanilla/window/WindowListener.kt +++ b/api/receptacle/src/main/kotlin/trplugins/menu/api/receptacle/vanilla/window/WindowListener.kt @@ -17,6 +17,7 @@ import trplugins.menu.api.receptacle.ReceptacleCloseEvent import trplugins.menu.api.receptacle.ReceptacleInteractEvent import trplugins.menu.api.receptacle.getViewingReceptacle import trplugins.menu.api.receptacle.vanilla.window.NMS.Companion.useStaticInventory +import trplugins.menu.api.receptacle.vanilla.window.StaticInventory.staticInventory @PlatformSide(Platform.BUKKIT) object WindowListener { @@ -67,6 +68,7 @@ object WindowListener { @SubscribeEvent fun onClick(e: InventoryClickEvent) { + (e.whoClicked as? Player)?.staticInventory ?: return if (e.inventory.holder is StaticInventory.Holder) { e.isCancelled = true @@ -81,6 +83,7 @@ object WindowListener { @SubscribeEvent fun onClose(e: InventoryCloseEvent) { + (e.player as? Player)?.staticInventory ?: return if (e.inventory.holder is StaticInventory.Holder) { val player = e.player as? Player ?: return val receptacle = player.getViewingReceptacle() as? WindowReceptacle ?: return @@ -91,6 +94,7 @@ object WindowListener { @SubscribeEvent fun onDrag(e: InventoryDragEvent) { + (e.whoClicked as? Player)?.staticInventory ?: return if (e.inventory.holder is StaticInventory.Holder) { e.isCancelled = true } diff --git a/gradle.properties b/gradle.properties index 8911322c..1c13b039 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=me.arasple.mc.trmenu -version=3.8.7 \ No newline at end of file +version=3.8.8 \ No newline at end of file diff --git a/plugin/src/main/kotlin/trplugins/menu/module/internal/listener/ListenerItemInteract.kt b/plugin/src/main/kotlin/trplugins/menu/module/internal/listener/ListenerItemInteract.kt index 7a3a4829..b85c68c4 100644 --- a/plugin/src/main/kotlin/trplugins/menu/module/internal/listener/ListenerItemInteract.kt +++ b/plugin/src/main/kotlin/trplugins/menu/module/internal/listener/ListenerItemInteract.kt @@ -47,23 +47,4 @@ object ListenerItemInteract { } } - class InventoryNMSImpl : InventoryNMS() { - - private val `clazz$CraftInventoryCustom$MinecraftInventory` = - obcClass("inventory.CraftInventoryCustom\$MinecraftInventory") - - override fun checkInventory(inventory: Inventory): Boolean { - return `clazz$CraftInventoryCustom$MinecraftInventory`.isInstance((inventory as CraftInventory).inventory) - } - - } - - abstract class InventoryNMS { - abstract fun checkInventory(inventory: Inventory): Boolean - - companion object { - val instance by lazy { nmsProxy() } - } - } - } \ No newline at end of file diff --git a/plugin/src/main/kotlin/trplugins/menu/module/internal/service/Shortcuts.kt b/plugin/src/main/kotlin/trplugins/menu/module/internal/service/Shortcuts.kt index a855d23d..f391a702 100644 --- a/plugin/src/main/kotlin/trplugins/menu/module/internal/service/Shortcuts.kt +++ b/plugin/src/main/kotlin/trplugins/menu/module/internal/service/Shortcuts.kt @@ -7,6 +7,7 @@ import org.bukkit.event.player.PlayerInteractEntityEvent import org.bukkit.event.player.PlayerSwapHandItemsEvent import org.bukkit.event.player.PlayerToggleSneakEvent import org.bukkit.inventory.EquipmentSlot +import org.bukkit.inventory.PlayerInventory import taboolib.common.platform.event.EventPriority import taboolib.common.platform.event.SubscribeEvent import taboolib.common.platform.function.adaptPlayer @@ -14,6 +15,7 @@ import taboolib.module.nms.MinecraftVersion import trplugins.menu.TrMenu import trplugins.menu.TrMenu.actionHandle import trplugins.menu.api.reaction.Reactions +import trplugins.menu.api.receptacle.vanilla.window.WindowListener import trplugins.menu.module.display.MenuSession import trplugins.menu.module.internal.data.Metadata @@ -111,6 +113,7 @@ object Shortcuts { @SubscribeEvent(ignoreCancelled = true) fun onClick(e: InventoryClickEvent) { val player = e.whoClicked as Player + if (e.inventory !is PlayerInventory) return if (player.openInventory.topInventory.holder == player.inventory.holder && e.slot < 0) { borderClick(player, e.click)