Now taking page changes into account when handling click events

This commit is contained in:
bluefireoly
2020-10-21 20:56:10 +02:00
parent 4c09ba34f2
commit 94f7b33c1f
2 changed files with 16 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ abstract class InventoryGUI<T : ForInventory>(
internal abstract val bukkitInventory: Inventory
internal var isInMove: Boolean = false
internal abstract fun loadPageUnsafe(
page: Int,
offsetHorizontally: Int = 0,
@@ -79,6 +81,14 @@ abstract class InventoryGUI<T : ForInventory>(
*/
fun getPage(page: Int?) = data.pages[page]
/**
* Reloads the current page.
*/
fun reloadCurrentPage() {
if (!isInMove)
loadPage(currentPage)
}
}
// Inventory GUI implementations

View File

@@ -22,6 +22,12 @@ object InventoryGUIHolder : AutoCloseable {
val clickedInv = it.clickedInventory ?: return@listen
val inv = registered.find { search -> search.isThisInv(clickedInv) } ?: return@listen
if (inv.isInMove) {
it.isCancelled = true
return@listen
}
val invPage = inv.currentPageInt
val slot = inv.data.pages[invPage]?.slots?.get(it.slot)