Now taking page changes into account when handling click events
This commit is contained in:
@@ -27,6 +27,8 @@ abstract class InventoryGUI<T : ForInventory>(
|
|||||||
|
|
||||||
internal abstract val bukkitInventory: Inventory
|
internal abstract val bukkitInventory: Inventory
|
||||||
|
|
||||||
|
internal var isInMove: Boolean = false
|
||||||
|
|
||||||
internal abstract fun loadPageUnsafe(
|
internal abstract fun loadPageUnsafe(
|
||||||
page: Int,
|
page: Int,
|
||||||
offsetHorizontally: Int = 0,
|
offsetHorizontally: Int = 0,
|
||||||
@@ -79,6 +81,14 @@ abstract class InventoryGUI<T : ForInventory>(
|
|||||||
*/
|
*/
|
||||||
fun getPage(page: Int?) = data.pages[page]
|
fun getPage(page: Int?) = data.pages[page]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads the current page.
|
||||||
|
*/
|
||||||
|
fun reloadCurrentPage() {
|
||||||
|
if (!isInMove)
|
||||||
|
loadPage(currentPage)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inventory GUI implementations
|
// Inventory GUI implementations
|
||||||
|
@@ -22,6 +22,12 @@ object InventoryGUIHolder : AutoCloseable {
|
|||||||
val clickedInv = it.clickedInventory ?: return@listen
|
val clickedInv = it.clickedInventory ?: return@listen
|
||||||
|
|
||||||
val inv = registered.find { search -> search.isThisInv(clickedInv) } ?: 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 invPage = inv.currentPageInt
|
||||||
|
|
||||||
val slot = inv.data.pages[invPage]?.slots?.get(it.slot)
|
val slot = inv.data.pages[invPage]?.slots?.get(it.slot)
|
||||||
|
Reference in New Issue
Block a user