-
Notifications
You must be signed in to change notification settings - Fork 1
Creating an inventory
Creating on is rather simple, you take a PluginInventory
instance 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 section will explain further editing you can do to the PluginInventory object!
This is rather simple, it may be achieved like so:
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.setInventorySize(18)
.setDisplayName("&b&lNew Name");
To add a InventoryHolder, you first need to have a InventoryHolder created, you can view more here and here
Once you have your holder, simple add it to the PluginInventory instance:
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.setInventoryHolder(yourHolder);
This library comes with a very extensive EventApi for inventories!
WARNING!! If you using anything with events with this library PLEASE look into this method to register the PluginInventory to the Event Bust!!!
Adding an onClose event can be added like so:
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.onClose((closeEvent) -> {
// Close event matches InventoryCloseEvent: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryCloseEvent.html
});
Adding an onOpen event can be added like so:
PluginInventory inventory = new PluginInventory(9, "&a&lInventory");
.onOpen((openEvent) -> {
// Open event matches InventoryOpenEvent: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryOpenEvent.html
});
Please note, if you are wanting to handle click event per item, please see ClickableItem
To add a onClick event can be added like so:
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.onClick((onClick) -> {
// Click event matches InventoryCLickEvent: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryClickEvent.html
});
Page written by: Dalton Burchard
- Your main class and you
- Editing API Settings (Optional)
- Creating an PluginInventory
- Creating Clickable items
- (Not added yet) Examples