-
Notifications
You must be signed in to change notification settings - Fork 1
Creating an inventory
Creating a Inventory is rather simple, you take a PluginInventory
class and initialize it like so:
PluginInventory inventory = new PluginInventory(9, "&a&lInventory");
You may notice there is 2 arguments, the 1st argument is for the inventory slot count, which goes by increments of 9 up to a maximum of 54. The second argument is what the inventory will be named.
This is rather simple, it may be achieved like so:
DO NOTE!! You cannot change a Inventories plugin name once the inventory is opened, this is a limitation in Bukkit itself, without creating some hacky work-around
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.setInventorySize(18)
.setDisplayName("&b&lNew Name")
.setInventoryType(InventoryType.ANVIL); // Events for all types of inventories have no been added yet, with time :)
Another thing to mention, ALL methods of PluginInventory are chainable.
An inventory can have specific event handling for when the inventory opens, closes and is clicked
Notice You are NOT meant to use the onClick() event as a way of handling items clicked, for that view Clickable Items this guide shows you how to handle specific item click events as well as adding items to the inventory, with a very unique API :)
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.onOpen((onOpen) -> {
InventoryOpenEvent event = onOpen.openEvent();
// Do things with event, or just in general
})
.onClose((onClose) -> {
InventoryCloseEvent event = onClose.closeEvent();
// Do things with event or just in general
})
.onClick((onClick) -> {
InventoryClickEvent event = onClick.clickEvent();
// Do things with event, or just in general
// IMPORTANT NOTE ABOUT CANCELLING INVENTORY CLICK EVENTS
// This event is processed after a ClickableItem's click event has been fired
// If you set a ClickableItem's click event to not cancelled, but cancel in this event
// this event will take priority over the cancellation
});
Page written by: Dalton Burchard
- Your main class and you
- Editing API Settings (Optional)
- Creating an PluginInventory
- Creating Clickable items
- (Not added yet) Examples