Skip to content

Commit 884a9df

Browse files
committed
Clear inventory before opening player inventory
1 parent 297bfbd commit 884a9df

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

next/src/main/kotlin/org/incendo/interfaces/next/view/PlayerInterfaceView.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,18 @@ public class PlayerInterfaceView internal constructor(
3535
InterfacesListeners.INSTANCE.setOpenInterface(player.uniqueId, this)
3636
}
3737

38-
// Trigger onOpen manually because there is no real inventory being opened
39-
onOpen()
38+
// Double-check that this inventory is open now!
39+
if (isOpen(player)) {
40+
// Clear the player's inventory!
41+
player.inventory.clear()
42+
if (player.openInventory.topInventory.type == InventoryType.CRAFTING) {
43+
player.openInventory.topInventory.clear()
44+
}
45+
player.openInventory.cursor = null
46+
47+
// Trigger onOpen manually because there is no real inventory being opened
48+
onOpen()
49+
}
4050
}
4151

4252
override fun close() {

0 commit comments

Comments
 (0)