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

29 lines
702 B
Kotlin
Raw Normal View History

2023-01-28 11:32:16 +00:00
@file:Suppress("PackageDirectoryMismatch")
2023-04-09 23:11:52 +00:00
package xyz.xenondevs.invui.inventory
2023-01-28 11:32:16 +00:00
import org.bukkit.inventory.ItemStack
/**
* Gets a copy of [ItemStack] placed on that [slot].
*/
2023-04-09 23:11:52 +00:00
operator fun Inventory.get(slot: Int): ItemStack? = getItem(slot)
2023-01-28 11:32:16 +00:00
/**
* Adds the given [items] to the inventory.
*/
2023-04-09 23:11:52 +00:00
operator fun Inventory.plusAssign(items: Iterable<ItemStack>) {
2023-01-28 11:32:16 +00:00
items.forEach { addItem(null, it) }
}
/**
* Adds the given [item] to the inventory.
*/
2023-04-09 23:11:52 +00:00
operator fun Inventory.plusAssign(item: ItemStack) {
2023-01-28 11:32:16 +00:00
addItem(null, item)
}
/**
2023-04-09 23:11:52 +00:00
* Checks if the [Inventory] contains an [ItemStack] similar to the given [item].
2023-01-28 11:32:16 +00:00
*/
2023-04-09 23:11:52 +00:00
operator fun Inventory.contains(item: ItemStack) = containsSimilar(item)