InvUI/invui-kotlin/src/main/kotlin/xyz/xenondevs/invui/Guis.kt

72 lines
2.1 KiB
Kotlin
Raw Normal View History

2023-01-28 11:32:16 +00:00
@file:Suppress("PackageDirectoryMismatch")
package xyz.xenondevs.invui.gui
2023-01-28 11:32:16 +00:00
import xyz.xenondevs.invui.item.Item
2023-01-28 11:32:16 +00:00
/**
* Gets the [SlotElement] placed on that slot.
2023-01-28 15:09:05 +00:00
*
2023-01-28 11:32:16 +00:00
* @param slot The slot index
* @return The [SlotElement] placed on that slot or null if there is none
*/
operator fun Gui.get(slot: Int): SlotElement? = getSlotElement(slot)
2023-01-28 11:32:16 +00:00
/**
* Gets the [SlotElement] placed on these coordinates.
2023-01-28 15:09:05 +00:00
*
2023-01-28 11:32:16 +00:00
* @param x The x coordinate of the slot
* @param y The y coordinate of the slot
* @return The [SlotElement] placed on that slot or null if there is none
*/
operator fun Gui.get(x: Int, y: Int): SlotElement? = getSlotElement(x, y)
2023-01-28 11:32:16 +00:00
/**
* Sets the [SlotElement] on that slot.
*
* @param slot The slot index
* @param element The [SlotElement] to set or null to remove the current one
*/
operator fun Gui.set(slot: Int, element: SlotElement?) = setSlotElement(slot, element)
2023-01-28 11:32:16 +00:00
/**
* Sets the [SlotElement] on these coordinates.
2023-01-28 15:09:05 +00:00
*
2023-01-28 11:32:16 +00:00
* @param x The x coordinate of the slot
* @param y The y coordinate of the slot
* @param element The [SlotElement] to set or null to remove the current one
*/
operator fun Gui.set(x: Int, y: Int, element: SlotElement?) = setSlotElement(x, y, element)
2023-01-28 11:32:16 +00:00
/**
* Sets the [Item] on that slot.
2023-01-28 15:09:05 +00:00
*
2023-01-28 11:32:16 +00:00
* @param slot The slot index
* @param item The [Item] to set or null to remove the current one
*/
operator fun Gui.set(slot: Int, item: Item?) = setItem(slot, item)
2023-01-28 11:32:16 +00:00
/**
* Sets the [Item] on these coordinates.
2023-01-28 15:09:05 +00:00
*
2023-01-28 11:32:16 +00:00
* @param x The x coordinate of the slot
* @param y The y coordinate of the slot
* @param item The [Item] to set or null to remove the current one
*/
operator fun Gui.set(x: Int, y: Int, item: Item?) = setItem(x, y, item)
2023-01-28 11:32:16 +00:00
/**
* Adds the given [elements].
2023-01-28 15:09:05 +00:00
*
2023-01-28 11:32:16 +00:00
* @param elements The [SlotElements][SlotElement] to add.
*/
@JvmName("plusAssignSlotElements")
operator fun Gui.plusAssign(elements: Iterable<SlotElement>) = elements.forEach { addSlotElements(it) }
2023-01-28 11:32:16 +00:00
/**
* Adds the given [items].
2023-01-28 15:09:05 +00:00
*
2023-01-28 11:32:16 +00:00
* @param items The [Items][Item] to add.
*/
@JvmName("plusAssignItems")
operator fun Gui.plusAssign(items: Iterable<Item>) = items.forEach { addItems(it) }