Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=me.arasple.mc.trmenu
version=3.8.7
version=3.8.8
Original file line number Diff line number Diff line change
Expand Up @@ -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<InventoryNMS>() }
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ 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
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

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down