-
Notifications
You must be signed in to change notification settings - Fork 1
Creating a ClickableItems
Dalton edited this page Apr 24, 2022
·
4 revisions
Creating a ClickableItem is rather simple:
ClickableItem item = new ClickableItem(Material.STONE, 1);
To handle the ClickableItem's InventoryClickEvent, you simply call the onClick functional interface:
ClickableItem item = new ClickableItem(Material.STONE, 1)
.onClick((onClick) -> {
final InventoryClickEvent event = onClick.clickEvent();
// Do things with event for this specific item
});
Make sure you read Creating a PluginInventory first before reading the rest of this guide
There is a few different methods:
- Setting a specific slots ClickableItem
ClickableItem item = new ClickableItem(Material.STONE, 1)
.onClick((onClick) -> {
final InventoryClickEvent event = onClick.clickEvent();
// Do things with event for this specific item
});
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.setClickableItemAtSlot(0, item);
- Filling all slots with a specific ClickableItem
ClickableItem item = new ClickableItem(Material.STONE, 1)
.onClick((onClick) -> {
final InventoryClickEvent event = onClick.clickEvent();
// Do things with event for this specific item
});
PluginInventory inventory = new PluginInventory(9, "&a&lInventory")
.fillWith(0, false);
You are probably about the boolean in this method, its called the overwrite:
When this boolean is true, it will forcefully overwrite all other ClickableItem's previously added to the PluginInventory
When its false, the only slots that get filled are slots that do not currently contain a ClickableItem
Page written by: Dalton Burchard
- Your main class and you
- Editing API Settings (Optional)
- Creating an PluginInventory
- Creating Clickable items
- (Not added yet) Examples