Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InventoryCloseEvent is called twice on AnvilGUIBuilder::open() #339

Closed
woodyn1002 opened this issue Jun 30, 2024 · 2 comments · Fixed by #346
Closed

InventoryCloseEvent is called twice on AnvilGUIBuilder::open() #339

woodyn1002 opened this issue Jun 30, 2024 · 2 comments · Fixed by #346

Comments

@woodyn1002
Copy link

woodyn1002 commented Jun 30, 2024

@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

@woodyn1002 woodyn1002 changed the title InventoryCloseEvent is called twice on AnvilGUI::open() InventoryCloseEvent is called twice on AnvilGUIBuilder::open() Jun 30, 2024
@KRIPA-YT
Copy link

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

@0dinD
Copy link
Collaborator

0dinD commented Aug 6, 2024

@woodyn1002 @KRIPA-YT I'm quite certain that I've found the problem and a fix for it, see #346. Feel free to build and use AnvilGUI from my PR branch if you want to help verify that it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants