did requested changes
This commit is contained in:
@@ -19,7 +19,7 @@ class GUIData<T : ForInventory>(
|
||||
val transitionTo: InventoryChangeEffect?,
|
||||
val transitionFrom: InventoryChangeEffect?,
|
||||
internal val generalOnClick: ((GUIClickEvent<T>) -> Unit)?,
|
||||
internal val onClose: ((InventoryCloseEvent) -> Unit)?
|
||||
internal val onClose: ((GUICloseEvent<T>) -> Unit)?
|
||||
)
|
||||
|
||||
abstract class GUI<T : ForInventory>(
|
||||
@@ -99,7 +99,7 @@ class GUIIndividual<T : ForInventory>(
|
||||
if (resetOnClose || data.onClose != null) {
|
||||
listen<InventoryCloseEvent> {
|
||||
if (data.onClose != null && playerInstances[it.player]?.bukkitInventory == it.inventory) {
|
||||
data.onClose.invoke(it)
|
||||
data.onClose.invoke(GUICloseEvent(it, playerInstances[it.player]!!, it.player as Player))
|
||||
}
|
||||
|
||||
if (resetOnClose) {
|
||||
|
@@ -47,7 +47,7 @@ class GUIBuilder<T : ForInventory>(
|
||||
|
||||
private var onClickElement: ((GUIClickEvent<T>) -> Unit)? = null
|
||||
|
||||
private var onClose: ((InventoryCloseEvent) -> Unit)? = null
|
||||
private var onClose: ((GUICloseEvent<T>) -> Unit)? = null
|
||||
|
||||
/**
|
||||
* Opens the builder for a new page and adds
|
||||
@@ -66,7 +66,11 @@ class GUIBuilder<T : ForInventory>(
|
||||
onClickElement = onClick
|
||||
}
|
||||
|
||||
fun onClose(onClose: (InventoryCloseEvent) -> Unit) {
|
||||
/**
|
||||
* A callback executed when the user closes
|
||||
* the inventory.
|
||||
*/
|
||||
fun onClose(onClose: (GUICloseEvent<T>) -> Unit) {
|
||||
this.onClose = onClose
|
||||
}
|
||||
|
||||
|
10
src/main/kotlin/net/axay/kspigot/gui/GUICloseEvent.kt
Normal file
10
src/main/kotlin/net/axay/kspigot/gui/GUICloseEvent.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.axay.kspigot.gui
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent
|
||||
|
||||
class GUICloseEvent<T : ForInventory>(
|
||||
val bukkitEvent: InventoryCloseEvent,
|
||||
val guiInstance: GUIInstance<T>,
|
||||
val player: Player,
|
||||
)
|
Reference in New Issue
Block a user