Skip to content

Commit

Permalink
Clear inventory before opening player inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Oct 28, 2023
1 parent 297bfbd commit 884a9df
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,18 @@ public class PlayerInterfaceView internal constructor(
InterfacesListeners.INSTANCE.setOpenInterface(player.uniqueId, this)
}

// Trigger onOpen manually because there is no real inventory being opened
onOpen()
// Double-check that this inventory is open now!
if (isOpen(player)) {
// Clear the player's inventory!
player.inventory.clear()
if (player.openInventory.topInventory.type == InventoryType.CRAFTING) {
player.openInventory.topInventory.clear()
}
player.openInventory.cursor = null

// Trigger onOpen manually because there is no real inventory being opened
onOpen()
}
}

override fun close() {
Expand Down

0 comments on commit 884a9df

Please sign in to comment.