From e1f28658c297bdfa80034acf82fb66f135624c32 Mon Sep 17 00:00:00 2001 From: KingsDev <63374258+KingsMMA@users.noreply.github.com> Date: Sat, 7 Dec 2024 22:25:21 +1000 Subject: [PATCH] Added javadoc, changed to all clicks while open --- src/main/kotlin/gg/flyte/twilight/gui/GUI.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/gg/flyte/twilight/gui/GUI.kt b/src/main/kotlin/gg/flyte/twilight/gui/GUI.kt index aa4ac6a..acbb9c3 100644 --- a/src/main/kotlin/gg/flyte/twilight/gui/GUI.kt +++ b/src/main/kotlin/gg/flyte/twilight/gui/GUI.kt @@ -30,8 +30,8 @@ class GUI(val title: Component, val size: Int, val type: InventoryType, val cont lateinit var viewer: Player private val clickEvent = event { + if (inventory == this@GUI.inventory) slotAction[-1]?.invoke(this) if (clickedInventory != this@GUI.inventory) return@event - slotAction[-1]?.invoke(this) slotAction[slot]?.invoke(this) } @@ -41,6 +41,9 @@ class GUI(val title: Component, val size: Int, val type: InventoryType, val cont } } + /** + * Set the action to be executed when the player clicks on any slot while the GUI is open. + */ fun onClick(action: InventoryClickEvent.() -> Unit) { slotAction[-1] = action }