-
Notifications
You must be signed in to change notification settings - Fork 0
KItem
KItems are a wrapper calls for the default ItemStack in bukkit, giving some more utility functions and most importantly are saved using NBT Data.
Currently, if you enable items to be dragged out of an inventory, using the DraggingMode.GLOBAL property, the items are not able to stack, due to their different kind of saved UUIDs. I am working on a implementation to fix this issue, in a future releas.
To create a new item you can use the kItem builder method like the following:
val item = kItem(Material.PAPER, 1) {}
Each item, if its not an air item, will be given a UUID, to easily identify it when clicked inside an inventory, using NBT Data
KIA provides some util functions, so you don't have to access the itemmeta, as often. The most common methods should be covered by using:
Currently, only the click event is modelled in KIA, to listen to the click event, you can use the onClick function, and pass your handler to the item like the following:
kItem.onClick { kItem, player ->
//do something
}
This function will always be called, also when the event is cancelled by KIA. If other sources cancel the event with a higher priority, the event might not trigger.
To make item management easier, KIA has a simple parent system in place. The parent in this case, will be a AbstractContentContainer, and can be used to gather information about the parent inventory. Parent inventories, must not be an actual inventory, but rather a content container. So a KRow can also be a parent container.
In the case you know the exact type of the parent, you can also cast it to the parent like the following:
val parentInv = kItem.parent as KInventory
Parent containers are set, as soon as the item is set inside them. The corresponding implementation of the container will handle this for you. If you implement your own containers, you must handle this functionality.