Skip to content

Commit

Permalink
Added javadoc, changed to all clicks while open
Browse files Browse the repository at this point in the history
  • Loading branch information
KingsMMA committed Dec 7, 2024
1 parent 13c1930 commit e1f2865
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/kotlin/gg/flyte/twilight/gui/GUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<InventoryClickEvent> {
if (inventory == this@GUI.inventory) slotAction[-1]?.invoke(this)
if (clickedInventory != this@GUI.inventory) return@event
slotAction[-1]?.invoke(this)
slotAction[slot]?.invoke(this)
}

Expand All @@ -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
}
Expand Down

0 comments on commit e1f2865

Please sign in to comment.