KInventory

Models a helper class to create bukkit inventories with ease, and provide helper functions to minimize boilerplate code

Bukkit inventories are therefore split into their global slots (0 - size) and their rows (size / 9) - given the inventory type supports rows

An inventory can hold rows, so rows can be reused at any point in the inventory.

Author

Devin

Since

1.0.0

Inheritors

Properties

Link copied to clipboard

All animations Identifier maps to the animation

Link copied to clipboard
abstract val content: MutableMap<Int, KItem>

Content of the container

Link copied to clipboard

The current animation if one is running

Link copied to clipboard
abstract var id: UUID

The unique ID of this identifiable

Link copied to clipboard
abstract var inventories: MutableList<Inventory>

Client side inventory instances

Link copied to clipboard

Sets whether the items can be clicked while the inventory is inside an animation

Link copied to clipboard

Animation which will be played when the inventory is opened

Link copied to clipboard
abstract var title: Component?

Title of the inventory rendered in the bukkit inventory

Link copied to clipboard
abstract var views: MutableList<InventoryView>

Views which currently look at the inventory

Functions

Link copied to clipboard
abstract fun addAnimation(identifier: String, animation: Animation<KInventory>)

Adds the animation

Link copied to clipboard
abstract fun clearInventory()

Clears the inventory from all items inside it

Link copied to clipboard
abstract fun closed()

Sets the inventory to closed Should be called when the inventory has been closed.

Link copied to clipboard
abstract fun getItems(): Map<Int, KItem>

Returns all the items in the inventory which have been set

Link copied to clipboard

Returns the KInventoryHolder of this inventory

Link copied to clipboard
abstract fun getRowFor(index: Int): KRow

Gets the row for the given index This will create a new row for the returned value

Link copied to clipboard
abstract fun getRowForItem(item: KItem): KRow?
Link copied to clipboard
abstract fun getSlotForItem(item: KItem): Int
Link copied to clipboard
abstract fun hasID(): Boolean
Link copied to clipboard
abstract fun isAnimating(): Boolean

Whether the object is currently inside an animation

Link copied to clipboard
abstract fun isEqual(inventory: Inventory): Boolean

Checks whether the given inventory is the same inventory

Link copied to clipboard
abstract fun isOpened(): Boolean
Link copied to clipboard
abstract fun isPrivate(): Boolean

Checks whether the inventory is private. Private indicated that only one player at a time can open the same reference to a KInventory

Link copied to clipboard
abstract fun itemClicked(item: ItemStack, player: Player, event: InventoryClickEvent)

Notifies the inventory that the given item has been clicked by the given player

Link copied to clipboard
abstract fun onClose(action: KInventory.() -> Unit)

Executed when the inventory is closed To catch this the bukkit event is used

Link copied to clipboard
abstract fun onItemClicked(action: KInventory.(item: ItemStack, player: Player, event: InventoryClickEvent) -> Unit)

Executes the passed function, when a bukkit org.bukkit.inventory.ItemStack is clicked

Link copied to clipboard
abstract fun onOpen(action: KInventory.() -> Unit)

Executed when the inventory is opened To catch this the bukkit event is used

Link copied to clipboard
abstract fun opened()

Sets the inventory to opened Should be called when the inventory has been opened.

Link copied to clipboard
abstract fun setItem(slot: Int, value: KItem)

Sets the given item at the given position

abstract fun setItem(row: Int, slot: Int, item: KItem)

Sets the given item relative to the slot of the given row

Link copied to clipboard
abstract fun setRow(index: Int, row: KRow)

Sets the given row at the given index

Link copied to clipboard
abstract fun startAnimation(animation: Animation<KInventory>)

Starts the given animation, but will not save it

abstract fun startAnimation(identifier: String)

Starts the animation with the given identifier

Link copied to clipboard
abstract fun swapRow(row: KRow, otherRow: KRow)

Swaps two rows in an inventory

abstract fun swapRow(index: Int, otherIndex: Int)

Swaps two rows based on their index

Link copied to clipboard
abstract fun toBukkitInventory(): Inventory

Constructs the bukkit inventory from this KInventory with the current set content