Skip to content

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);

Handling the ClickableItem's InventoryClickEvent

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
    });

Adding ClickableItem to an inventory

Make sure you read Creating a PluginInventory first before reading the rest of this guide

There is a few different methods:

1. Setting a specific slots ClickableItem
   
    ```java

        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);
    ```

Clone this wiki locally