updated spigot and added on close function for closing a gui

This commit is contained in:
Skyslycer
2021-08-16 00:30:43 +02:00
parent d58193f161
commit e4681af822
3 changed files with 19 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ class GUIData<T : ForInventory>(
val transitionTo: InventoryChangeEffect?,
val transitionFrom: InventoryChangeEffect?,
internal val generalOnClick: ((GUIClickEvent<T>) -> Unit)?,
internal val onClose: ((InventoryCloseEvent) -> Unit)?
)
abstract class GUI<T : ForInventory>(
@@ -95,9 +96,15 @@ class GUIIndividual<T : ForInventory>(
}
init {
if (resetOnClose) {
if (resetOnClose || data.onClose != null) {
listen<InventoryCloseEvent> {
deleteInstance(it.player as? Player ?: return@listen)
if (data.onClose != null && playerInstances[it.player]?.bukkitInventory == it.inventory) {
data.onClose.invoke(it)
}
if (resetOnClose) {
deleteInstance(it.player as? Player ?: return@listen)
}
}
}