🧱
Items
View how to create and customize Menu items.
Relevant Classes:
Menu
MenuItem
A Menu Item consists of various things, those being:
  • Identifier - This is just a unique identifier used by JustAPI
  • Updatable - This determines whether or not this Menu Item should be updated
  • ItemStack - This is the Spigot ItemStack instance, used for displaying the Menu Item
  • Slots - This is a list of slots the Menu Item is assigned to, used for displaying the Menu Item
  • Metadata - This is used by the Developer to access unique information about the Menu Item
  • Actions - These are used to determine what should happen when clicking the Menu Item
Each Menu Item has it's own logic and purpose in a Menu. Menu Items are the foundation of a Menu and are what give the Menu it's function.

Examples

Configuration
Code
All Menu Item variables must be case-sensitive to be recognized.
A Menu Item MUST have a material defined.
Creating a Menu Item via configuration is as simple as can be!
Example-Menu:
Title: "&eExample Menu"
Size: 9
Items:
Example-Item:
Slot: 0 # The slot to place the item, starts with 0
Material: "GRAY_STAINED_GLASS_PANE" # The material of the ItemStack
Name: "&cExample" # The name of the ItemStack, supports colors
Lore: # The lore of the ItemStack, supports colors
- "&7Example Item"
- ""
- "&aSecond Line"
If setup correctly, the Menu will automatically recognize and create the item from the configuration.
The Menu Item's identifier MUST be unique.
Creating a Menu Item from code is a bit more complex, but allows more freedom.
This example will be using this constructor, there are others available with more capabilities.
Menu menu;
ItemStack itemStack = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName("§cExample");
meta.setLore(Arrays.asList("§7Example Item", "", "§aSecond Line"));
itemStack.setItemMeta(meta);
MenuItem item = new MenuItem("Example-Item", itemStack,
Arrays.asList(0), false);
// Do things!
menu.addItem(item);
Now that you have created the item, you can do various things to it prior to adding it to the Menu.
Copy link