@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)
}
While the player has an inventory opened,
AnvilGUIBuilder::open()
callsInventoryCloseEvent
twice. tested in 1.20.4