@@ -211,12 +211,14 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
211211 semaphore.release()
212212 }
213213
214- protected open fun drawPaneToInventory (opened : Boolean ) {
214+ protected open fun drawPaneToInventory (drawNormalInventory : Boolean , drawPlayerInventory : Boolean ) {
215215 var madeChanges = false
216216 pane.forEach { row, column, element ->
217217 // We defer drawing of any elements in the player inventory itself
218218 // for later unless the inventory is already open.
219- if (! opened && currentInventory.isPlayerInventory(row, column)) return @forEach
219+ val isPlayerInventory = currentInventory.isPlayerInventory(row, column)
220+ if (! isPlayerInventory && drawNormalInventory || isPlayerInventory && drawPlayerInventory) return @forEach
221+
220222 currentInventory.set(row, column, element.itemStack.apply { this ?.let { backing.itemPostProcessor?.invoke(it) } })
221223 madeChanges = true
222224 }
@@ -229,15 +231,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
229231 // Whenever we open the inventory we draw all elements in the player inventory
230232 // itself. We do this in this hook because it runs after InventoryCloseEvent so
231233 // it properly happens as the last possible action.
232- var madeChanges = false
233- pane.forEach { row, column, element ->
234- if (! currentInventory.isPlayerInventory(row, column)) return @forEach
235- currentInventory.set(row, column, element.itemStack.apply { this ?.let { backing.itemPostProcessor?.invoke(it) } })
236- madeChanges = true
237- }
238- if (madeChanges) {
239- Bukkit .getPluginManager().callEvent(DrawPaneEvent (player))
240- }
234+ drawPaneToInventory(drawNormalInventory = false , drawPlayerInventory = true )
241235 }
242236
243237 protected open fun requiresNewInventory (): Boolean = firstPaint
@@ -263,7 +257,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
263257 // updates on menus that have closed do not affect future menus that actually
264258 // ended up being opened.
265259 val isOpen = isOpen(player)
266- drawPaneToInventory(isOpen)
260+ drawPaneToInventory(drawNormalInventory = true , drawPlayerInventory = isOpen)
267261 callback(createdInventory)
268262
269263 if ((openIfClosed && ! isOpen) || createdInventory) {
0 commit comments