WesJD / AnvilGUI

Capture user input in Minecraft through an anvil GUI in under 20 lines of code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InventoryCloseEvent is called twice on AnvilGUIBuilder::open()

woodyn1002 opened this issue · comments

@EventHandler
fun onInventoryClick(event: InventoryClickEvent) {
    if (!isCustomGui(event.inventory)) return

    if (event.rawSlot == 0) {
        val anvilGuiBuilder = createAnvilGuiBuilder()
        anvilGuiBuilder.open(event.whoClicked as Player)
    }
}

@EventHandler
fun onInventoryClose(event: InventoryCloseEvent) {
    println(event)
}
[19:09:36] [Server thread/INFO]: org.bukkit.event.inventory.InventoryCloseEvent@6d7d67f
[19:09:37] [Server thread/INFO]: org.bukkit.event.inventory.InventoryCloseEvent@262b0318

While the player has an inventory opened, AnvilGUIBuilder::open() calls InventoryCloseEvent twice.
tested in 1.20.4

Confirm, is the same on 1.21 aswell, it really messes up my plugin logic