Items

Let's add a new item in your menu !

What is a GuiItem ?

GuiItem is item used by KapEasyMenu Plugin. It is a useful Item Class to describe its behave with specifics actions.

Let's see how to create a nomal GuiItem

//since 2.0.0
GuiItem myItem(MyPlugin plugin, ItemStack minecraftItem) {
    GuiItem result = new GuiItem(plugin, minecraftItem);
    return result;
}

//since 1.1.1
GuiItem myItem() {
    GuiItem result = new GuiItem(Material.MATERIAL);
    
    return result;
}

//since 1.0.1
GuiItem myItem2(MyPlugin plugin) {
    GuiItem result = new GuiItem(plugin, Material.MATERIAL);
    
    return result;
}

Let's set more settings

You can set :

  • ItemStack amount -> set the amount of items

  • Item title -> set your item title

  • Item Lores -> set your item lores

  • Cancel Event -> cancel the event on your item click (in game)

let's code these modifications

GuiItem myItem() {
    GuiItem item = new GuiItem(Material.MATERIAL)
        .setAmount(3)
        .setName("My Item Name")
        .setLore(new String[]{"§7My", "Lores !"})
        .setDisableEvent(true); //with this line the item cannot be move from its slot
    return item;
}

Getters

There is severale useful getters :

  • getItem() -> it returns the ItemStack

  • getPlugin() -> it returns the JavaPlugin attached to your item

  • isDisableEvent() -> it returns if your item disable InventoryClickEvent

  • getLore() -> return lore of your item

  • getName() -> return name of your item

  • getAction(ItemActions) -> return the lambda you set with an action (Check doc)

Last updated