-
Notifications
You must be signed in to change notification settings - Fork 0
KInventory
To build a default inventory, with default bukkit behaviour, you should use the kInventory builder method:
val inventory = kInventory(sender, 5.rows, InventoryType.CHEST) {}
This will build an inventory with the size of 5x9 with a chest type. For the holder, you can use any kind of Bukkit player.
To make it easier to handle rows, you can use the
.rows
extension function on an integer.
Building the inventory is done inside the context delivered by the builder function. You can use the methods of the inventory to build it.
val inventory = kInventory(sender, 5.rows, InventoryType.CHEST) {
setItem(1, 4, kItem(Material.DIAMOND_PICKAXE) {})
}
This will set the given item in row 1 slot 4. Learn more here
Items can be set using 2 ways.
- Using the setItem method
- Using a kRow to directly set a row
To learn about the concept of animations take a look at here.
Inside the inventory, you can set an openingAnimation, which will play as soon as the inventory is opened by a player. Using the isAnimating() function you can also check if the inventory is currently inside an animation.
Animations can also be saved, using the "animations" mapping in the inventory. You can then access them later, if required. Then using the startAnimation() method, you can play an animation.
To listen to events on the inventory you can use one of the close/open listeners like the following:
val inventory = kInventory(sender, 5.rows, InventoryType.CHEST) {
onOpen {
// do something
}
onClose {
// do something
}
}