diff --git a/next/src/main/kotlin/org/incendo/interfaces/next/view/AbstractInterfaceView.kt b/next/src/main/kotlin/org/incendo/interfaces/next/view/AbstractInterfaceView.kt index 8ce7c4b..9db2331 100644 --- a/next/src/main/kotlin/org/incendo/interfaces/next/view/AbstractInterfaceView.kt +++ b/next/src/main/kotlin/org/incendo/interfaces/next/view/AbstractInterfaceView.kt @@ -216,24 +216,32 @@ public abstract class AbstractInterfaceView( } protected open fun drawPaneToInventory(opened: Boolean) { + var madeChanges = false pane.forEach { row, column, element -> // We defer drawing of any elements in the player inventory itself // for later unless the inventory is already open. if (!opened && currentInventory.isPlayerInventory(row, column)) return@forEach currentInventory.set(row, column, element.itemStack.apply { this?.let { backing.itemPostProcessor?.invoke(it) } }) + madeChanges = true + } + if (madeChanges) { + Bukkit.getPluginManager().callEvent(DrawPaneEvent(player)) } - Bukkit.getPluginManager().callEvent(DrawPaneEvent(player)) } override fun onOpen() { // Whenever we open the inventory we draw all elements in the player inventory // itself. We do this in this hook because it runs after InventoryCloseEvent so // it properly happens as the last possible action. + var madeChanges = false pane.forEach { row, column, element -> if (!currentInventory.isPlayerInventory(row, column)) return@forEach currentInventory.set(row, column, element.itemStack.apply { this?.let { backing.itemPostProcessor?.invoke(it) } }) + madeChanges = true + } + if (madeChanges) { + Bukkit.getPluginManager().callEvent(DrawPaneEvent(player)) } - Bukkit.getPluginManager().callEvent(DrawPaneEvent(player)) } protected open fun requiresNewInventory(): Boolean = firstPaint 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 0c6ae57..bfdf085 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 @@ -36,6 +36,9 @@ public class PlayerInterfaceView internal constructor( player.closeInventory() InterfacesListeners.INSTANCE.setOpenInterface(player.uniqueId, this) } + + // Trigger onOpen manually because there is no real inventory being opened + onOpen() } override fun close() {