From 884a9df2c9374b4987e5d85997e4348753bff840 Mon Sep 17 00:00:00 2001 From: Aeltumn Date: Wed, 25 Oct 2023 15:39:23 +0200 Subject: [PATCH] Clear inventory before opening player inventory --- .../interfaces/next/view/PlayerInterfaceView.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/next/src/main/kotlin/org/incendo/interfaces/next/view/PlayerInterfaceView.kt b/next/src/main/kotlin/org/incendo/interfaces/next/view/PlayerInterfaceView.kt index fc7ceb7..30330da 100644 --- a/next/src/main/kotlin/org/incendo/interfaces/next/view/PlayerInterfaceView.kt +++ b/next/src/main/kotlin/org/incendo/interfaces/next/view/PlayerInterfaceView.kt @@ -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() {