Using MenuItemStack
MenuItemStack is a utility class in zMenu that allows you to define and reuse item representations (name, lore, material, etc.) from configuration files.
In this guide, you'll learn how to load and build MenuItemStack objects.
Step 1: Load a MenuItemStack
There are two ways to load a MenuItemStack using the InventoryManager.
From a YamlConfiguration
MenuItemStack itemStack = inventoryManager.loadItemStack(configuration, "path.to.item", file);configuration: AYamlConfigurationinstance"path.to.item": Path to the section in the YAMLfile: The file source (for error tracking)
From a Map (programmatic)
MenuItemStack itemStack = inventoryManager.loadItemStack(file, "path", map);map: AMap<String, Object>that contains the item configurationfile: Source file"path": Identifier path used for context
Step 2: Build the ItemStack
Once loaded, you can build the final ItemStack using one of the following methods:
Or with additional options:
player: The player the item is built for (can be used for placeholders)useCache: Set to false if you want to force rebuild instead of cached copyplaceholders: Optional dynamic values to insert in name/lore
Example YAML
You can load this item using:
And then:
Result
You now have a reusable, customizable item system that supports placeholders, dynamic building, and centralized configuration.
This is especially useful for:
Reward items
Display icons
Buttons
Static items in menus
Last updated