@@ -216,24 +216,32 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, P : Pane>(
216216 }
217217
218218 protected open fun drawPaneToInventory (opened : Boolean ) {
219+ var madeChanges = false
219220 pane.forEach { row, column, element ->
220221 // We defer drawing of any elements in the player inventory itself
221222 // for later unless the inventory is already open.
222223 if (! opened && currentInventory.isPlayerInventory(row, column)) return @forEach
223224 currentInventory.set(row, column, element.itemStack.apply { this ?.let { backing.itemPostProcessor?.invoke(it) } })
225+ madeChanges = true
226+ }
227+ if (madeChanges) {
228+ Bukkit .getPluginManager().callEvent(DrawPaneEvent (player))
224229 }
225- Bukkit .getPluginManager().callEvent(DrawPaneEvent (player))
226230 }
227231
228232 override fun onOpen () {
229233 // Whenever we open the inventory we draw all elements in the player inventory
230234 // itself. We do this in this hook because it runs after InventoryCloseEvent so
231235 // it properly happens as the last possible action.
236+ var madeChanges = false
232237 pane.forEach { row, column, element ->
233238 if (! currentInventory.isPlayerInventory(row, column)) return @forEach
234239 currentInventory.set(row, column, element.itemStack.apply { this ?.let { backing.itemPostProcessor?.invoke(it) } })
240+ madeChanges = true
241+ }
242+ if (madeChanges) {
243+ Bukkit .getPluginManager().callEvent(DrawPaneEvent (player))
235244 }
236- Bukkit .getPluginManager().callEvent(DrawPaneEvent (player))
237245 }
238246
239247 protected open fun requiresNewInventory (): Boolean = firstPaint
0 commit comments