diff --git a/src/main/kotlin/net/axay/kspigot/inventory/elements/InventoryGUISpaceCompound.kt b/src/main/kotlin/net/axay/kspigot/inventory/elements/InventoryGUISpaceCompound.kt index f5b8a2b6..afe1069d 100644 --- a/src/main/kotlin/net/axay/kspigot/inventory/elements/InventoryGUISpaceCompound.kt +++ b/src/main/kotlin/net/axay/kspigot/inventory/elements/InventoryGUISpaceCompound.kt @@ -47,6 +47,12 @@ class InventoryGUISpaceCompound( } internal var scrolledLines: Int = 0 + set(value) { + if (((value - 1) * invType.dimensions.width) < content.size) { + field = value + onChange() + } + } private var contentSort: () -> Unit = { } @@ -76,6 +82,10 @@ class InventoryGUISpaceCompound( realInternalSlots.sort() } + internal fun onChange() { + registeredGUIs.forEach { it.reloadCurrentPage() } + } + internal fun registerGUI(gui: InventoryGUI<*>) { registeredGUIs += gui } @@ -108,7 +118,7 @@ class InventoryGUISpaceCompound( fun addContent(elements: Collection) { content += elements contentSort.invoke() - registeredGUIs.forEach { it.reloadCurrentPage() } + onChange() } } \ No newline at end of file