### Player Data Management Examples Source: https://docs.groupez.dev/zmenu/configurations/commands-permissions Illustrates how to manage player-specific data, including setting, adding, getting, and listing data keys. ```bash /zm players set Notch coins 100 ``` ```bash /zm players add Notch coins 50 ``` ```bash /zm players get Notch coins ``` ```bash /zm players keys Notch ``` -------------------------------- ### Complete Currency System Example Source: https://docs.groupez.dev/zmenu/development/api-player-data A comprehensive example demonstrating a currency system using the DataManager API. It includes methods for getting, setting, adding, removing, and checking coins. ```java package com.example.currency; import fr.maxlego08.menu.api.MenuPlugin; import fr.maxlego08.menu.api.DataManager; import org.bukkit.entity.Player; public class CurrencyManager { private final DataManager dataManager; private static final String COINS_KEY = "coins"; public CurrencyManager(MenuPlugin menuPlugin) { this.dataManager = menuPlugin.getDataManager(); } public int getCoins(Player player) { return dataManager.getData(player, COINS_KEY) .map(Integer::parseInt) .orElse(0); } public void setCoins(Player player, int amount) { dataManager.setData(player, COINS_KEY, String.valueOf(Math.max(0, amount))); } public void addCoins(Player player, int amount) { int current = getCoins(player); setCoins(player, current + amount); } public boolean removeCoins(Player player, int amount) { int current = getCoins(player); if (current >= amount) { setCoins(player, current - amount); return true; } return false; } public boolean hasCoins(Player player, int amount) { return getCoins(player) >= amount; } } ``` -------------------------------- ### Complete commands.yml Configuration Example Source: https://docs.groupez.dev/zmenu/configurations/custom-commands A comprehensive example of the commands.yml file, demonstrating how to define various commands with their inventories, permissions, and aliases. ```yaml # commands/commands.yml commands: # Main server menu menu: command: menu inventory: main_menu aliases: - gui - server actions: - type: sound sound: BLOCK_CHEST_OPEN # Shop with permission shop: command: shop inventory: shop_main permission: "server.shop" aliases: - store - market - buy # VIP shop vipshop: command: /vipshop inventory: vip_shop permission: "server.vip.shop" aliases: - vs # Warps menu warps: command: warps inventory: warps_menu permission: "server.warps" aliases: - warp - w # Player profile profile: command: /profile inventory: player_profile aliases: - stats - me # Help menu help: command: /serverhelp inventory: help_menu aliases: - faq - info # Admin panel admin: command: /adminpanel inventory: admin_menu permission: "server.admin" aliases: - ap - adminmenu ``` -------------------------------- ### Vanilla Material Example Source: https://docs.groupez.dev/zmenu/configurations/items/item Example of configuring an item with a standard Minecraft material. ```yaml # Vanilla material material: DIAMOND_SWORD ``` -------------------------------- ### Basic Pagination Example Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/pagination An example demonstrating a paginated menu with specific slots, elements including lore, and a custom item template with placeholders. ```yaml size: 54 name: "&8Paginated Menu" items: # Paginated content area content: type: PAGINATION slots: - 10-16 - 19-25 - 28-34 elements: - display_name: "Diamond" lore_value: "Valuable" - display_name: "Emerald" lore_value: "Traded" item: material: PAPER name: "&e&l%display_name%" lore: - "&7This item is %lore_value%" ``` -------------------------------- ### Example with Different Actions per Click Type Source: https://docs.groupez.dev/zmenu/configurations/requirements This example demonstrates setting up distinct requirement groups for 'buy-one' (left-click) and 'buy-stack' (right-click) actions. Each group has specific balance requirements and success actions, including console commands. ```yaml click-requirement: buy-one: clicks: - LEFT requirements: - type: placeholder placeholder: "%vault_eco_balance%" action: SUPERIOR_OR_EQUAL value: 100 deny: - type: message messages: - "&cYou need $100!" success: - type: currency-withdraw amount: 100 - type: console-command commands: - "give %player% diamond 1" buy-stack: clicks: - RIGHT requirements: - type: placeholder placeholder: "%vault_eco_balance%" action: SUPERIOR_OR_EQUAL value: 6400 deny: - type: message messages: - "&cYou need $6400!" success: - type: currency-withdraw amount: 6400 - type: console-command commands: - "give %player% diamond 64" ``` -------------------------------- ### ItemsAdder Custom Material Example Source: https://docs.groupez.dev/zmenu/configurations/items/item Example of configuring an item with a custom item from the ItemsAdder plugin. ```yaml # ItemsAdder custom item material: "itemsadder:my_namespace:ruby_gem" ``` -------------------------------- ### Complete zMenu Integration Example Source: https://docs.groupez.dev/zmenu/development/api-introduction This example demonstrates how to hook into the zMenu plugin, handle cases where zMenu is not present, and open a zMenu inventory from your custom plugin. ```java package com.example.myplugin; import fr.maxlego08.menu.api.MenuPlugin; import fr.maxlego08.menu.api.InventoryManager; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; public class MyPlugin extends JavaPlugin { private MenuPlugin menuPlugin; @Override public void onEnable() { // Hook into zMenu this.menuPlugin = (MenuPlugin) Bukkit.getPluginManager().getPlugin("zMenu"); if (this.menuPlugin == null) { getLogger().severe("zMenu is required!"); Bukkit.getPluginManager().disablePlugin(this); return; } getLogger().info("MyPlugin enabled with zMenu integration!"); } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("Players only!"); return true; } Player player = (Player) sender; InventoryManager manager = menuPlugin.getInventoryManager(); // Open a zMenu inventory manager.getInventory("my-menu").ifPresent(inv -> { manager.openInventory(player, inv); }); return true; } } ``` -------------------------------- ### Open Inventory Examples Source: https://docs.groupez.dev/zmenu/configurations/commands-permissions Demonstrates how to open inventories for yourself or other players, with optional arguments and messages. ```bash /zm open shop ``` ```bash /zm open shop Notch ``` ```bash /zm open shop Notch "Welcome to the shop!" ``` -------------------------------- ### Complete Navigation Bar with PREVIOUS Button Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/previous An example showcasing a full navigation bar setup, including borders, PREVIOUS, BACK, HOME, and NEXT buttons, along with a page information display. ```yaml items: nav-left-border: slots: - 45 - 46 is-permanent: true item: material: BLACK_STAINED_GLASS_PANE name: "&8" previous: type: PREVIOUS slot: 47 is-permanent: true item: material: ARROW name: "&c&l← Previous" sound: UI_BUTTON_CLICK back: type: BACK slot: 48 is-permanent: true item: material: DARK_OAK_DOOR name: "&7&lBack" sound: UI_BUTTON_CLICK page-info: slot: 49 is-permanent: true item: material: BOOK name: "&6&lPage %page% of %maxPage%" lore: - "" - "&7Use arrows to navigate" home: type: HOME slot: 50 is-permanent: true item: material: NETHER_STAR name: "&e&lHome" sound: UI_BUTTON_CLICK next: type: NEXT slot: 51 is-permanent: true item: material: ARROW name: "&a&lNext →" sound: UI_BUTTON_CLICK nav-right-border: slots: - 52 - 53 is-permanent: true item: material: BLACK_STAINED_GLASS_PANE name: "&8" ``` -------------------------------- ### List Installed Expansions Source: https://docs.groupez.dev/zmenu/configurations/placeholders Use the `/papi list` command to see all currently installed PlaceholderAPI expansions. ```minecraft-command /papi list ``` -------------------------------- ### Example: Inventory Navigation with Pagination Source: https://docs.groupez.dev/zmenu/configurations/patterns An example of an inventory pattern (`patterns/pagination.yml`) that includes navigation buttons (`NEXT`, `PREVIOUS`). Ensure `enableMultiPage: true` is set for these buttons to function with inventory pagination. ```yaml name: "pagination" size: 54 enableMultiPage: true items: next: type: NEXT slot: 52 is-permanent: true item: material: PAPER name: "&fNext Page" previous: type: PREVIOUS slot: 49 is-permanent: true item: material: PAPER name: "&fPrevious Page" ``` -------------------------------- ### Basic NEXT Button Example Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/next A straightforward example of a NEXT button, including its type, slot, permanence, item material and name, and a click sound. ```yaml items: next: type: NEXT slot: 53 is-permanent: true item: material: ARROW name: "&a&lNext →" sound: UI_BUTTON_CLICK ``` -------------------------------- ### Complete Button Example with Purchase Logic Source: https://docs.groupez.dev/zmenu/configurations/buttons/button A comprehensive example of a button that requires a certain balance to purchase, with defined actions for success and failure. Includes item properties, click requirements, and post-purchase actions. ```yaml items: shop-item: slot: 13 type: NONE item: material: DIAMOND_SWORD name: "&6&lDiamond Sword" lore: - "&8&m─────────────────" - "" - "&7A powerful sword!" - "" - "&7Price: &a$500" - "&7Your balance: &e$%vault_eco_balance%" - "" - "&8&m─────────────────" - "" - "&e▸ Click to purchase" enchantments: - SHARPNESS,5 flags: - HIDE_ENCHANTS glow: true click-requirement: requirements: - type: placeholder placeholder: "%vault_eco_balance%" action: SUPERIOR_OR_EQUAL value: 500 deny: - type: message messages: - "&cYou need $500 to buy this!" - type: sound sound: ENTITY_VILLAGER_NO success: - type: console-command commands: - "eco take %player% 500" - "give %player% diamond_sword{Enchantments:[{id:sharpness,lvl:5}]} 1" - type: message messages: - "&aPurchase successful!" - "&7You bought a &6Diamond Sword&7!" - type: sound sound: ENTITY_PLAYER_LEVELUP - type: close ``` -------------------------------- ### Reload Commands Examples Source: https://docs.groupez.dev/zmenu/configurations/commands-permissions Shows how to reload various configurations, including all configurations, specific files, or individual inventories and commands. ```bash /zm reload ``` ```bash /zm reload inventory shop ``` ```bash /zm reload command warp ``` -------------------------------- ### Placeholder Syntax Example Source: https://docs.groupez.dev/zmenu/supported-plugins Demonstrates how to use PlaceholderAPI syntax within item configurations for dynamic display of player data. ```yaml item: material: DIAMOND name: "&6%player_name%'s Menu" lore: - "&7Balance: &a$%vault_eco_balance%" - "&7Playtime: &e%statistic_hours_played%h" ``` -------------------------------- ### Oraxen Custom Material Example Source: https://docs.groupez.dev/zmenu/configurations/items/item Example of configuring an item with a custom item from the Oraxen plugin. ```yaml # Oraxen custom item material: "oraxen:amethyst_sword" ``` -------------------------------- ### Example: Inventory Decoration Pattern Source: https://docs.groupez.dev/zmenu/configurations/patterns A concrete example of an inventory pattern file (`patterns/pattern_example.yml`) that defines decorative buttons. This pattern can then be applied to other inventories. ```yaml name: "pattern_example" size: 54 items: example1: isPermanent: true item: material: IRON_INGOT name: "&fExample of pattern" slots: - 0 - 8 - 45 - 53 ``` -------------------------------- ### Basic Main Menu Button Example Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/mainmenu A simple example of a MAIN_MENU button with a Nether Star icon and a click sound. This button is placed in slot 49. ```yaml items: main-menu: type: MAIN_MENU slot: 49 item: material: NETHER_STAR name: "&6&lMain Menu" sound: UI_BUTTON_CLICK ``` -------------------------------- ### Player Head Material Example Source: https://docs.groupez.dev/zmenu/configurations/items/item Example of configuring an item to use a player's head as the material. ```yaml # Player head material: "playerHead:%player%" ``` -------------------------------- ### Basic Menu Navigation Examples Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/inventory Configures multiple buttons to open different inventories ('shop', 'warps', 'settings') with custom items. ```yaml items: shop: type: INVENTORY slot: 11 inventory: "shop" item: material: GOLD_INGOT name: "&e&lShop" lore: - "&7Buy and sell items" - "" - "&e▸ Click to open" warps: type: INVENTORY slot: 13 inventory: "warps" item: material: ENDER_PEARL name: "&5&lWarps" lore: - "&7Teleport around the world" - "" - "&e▸ Click to open" settings: type: INVENTORY slot: 15 inventory: "settings" item: material: COMPARATOR name: "&c&lSettings" lore: - "&7Configure your preferences" - "" - "&e▸ Click to open" ``` -------------------------------- ### Inventory File Structure Example Source: https://docs.groupez.dev/zmenu/configurations/inventories/inventory Illustrates how inventories can be organized in the plugins/zMenu/inventories folder, including subfolders. ```yaml plugins/zMenu/inventories/ ├── main_menu.yml ├── shop.yml ├── warps/ │ ├── spawn.yml │ └── hub.yml └── admin/ └── admin_menu.yml ``` -------------------------------- ### ItemsAdder Custom Item Example Source: https://docs.groupez.dev/zmenu/supported-plugins Example of how to specify an item from the ItemsAdder plugin. The material format includes the plugin prefix and the item's namespace and identifier. ```yaml item: material: ITEMSADDER:my_namespace:ruby ``` -------------------------------- ### zHead Custom Material Example Source: https://docs.groupez.dev/zmenu/configurations/items/item Example of using a custom head from the zHead plugin as the item material. ```yaml # Custom head from zHead material: "zhd:123" ``` -------------------------------- ### MiniMessage Formatting Examples Source: https://docs.groupez.dev/zmenu/configurations/config-yml Examples of using MiniMessage for gradient and rainbow text, as well as bold and gold text. ```yaml name: "Gradient Text" lore: - "Rainbow!" - "Bold gold" ``` -------------------------------- ### Configure 'or' Requirement Source: https://docs.groupez.dev/zmenu/configurations/requirements Use 'or' requirements when a minimum number of sub-requirements must be met. This example requires either 'server.vip' or 'server.premium' permission. ```yaml requirements: - type: or minimum: 1 random: false requirements: - type: permission permission: "server.vip" - type: permission permission: "server.premium" ``` -------------------------------- ### Example of a Command File in a Subdirectory Source: https://docs.groupez.dev/zmenu/configurations/custom-commands Shows the content of a command file located in a subdirectory, following the standard command configuration format. ```yaml # commands/shop/shop_commands.yml commands: shop: command: shop inventory: shop_main buyweapons: command: /buyweapons inventory: shop_weapons ``` -------------------------------- ### MythicMobs Custom Item Example Source: https://docs.groupez.dev/zmenu/supported-plugins Example of how to specify a MythicMobs item. The material format uses the MYTHICMOBS prefix followed by the item's identifier. ```yaml item: material: MYTHICMOBS:SkeletonKingSword ``` -------------------------------- ### MiniMessage Syntax Examples Source: https://docs.groupez.dev/zmenu/configurations/informations Demonstrates various MiniMessage syntaxes for gradients, rainbow text, bolding, and clickable text within zMenu configurations. ```yaml name: "Gradient Text" lore: - "Rainbow text!" - "Bold gold text" - "Click to spawn" ``` -------------------------------- ### Slimefun Custom Item Example Source: https://docs.groupez.dev/zmenu/supported-plugins Example of how to specify a Slimefun item. The material format uses the SLIMEFUN prefix followed by the item's identifier. ```yaml item: material: SLIMEFUN:ELECTRIC_MOTOR ``` -------------------------------- ### PlaceholderAPI Integration Example Source: https://docs.groupez.dev/zmenu/configurations/informations Shows how to use PlaceholderAPI placeholders within zMenu configurations for dynamic text, such as player names and balances. ```yaml name: "&6%player_name%'s Profile" lore: - "&7Balance: &a$%vault_eco_balance%" - "&7Level: &e%player_level%" ``` -------------------------------- ### Dynamic Requirements with Placeholders Source: https://docs.groupez.dev/zmenu/configurations/placeholders Implement dynamic conditions for requirements using placeholders. This example checks if a player's economy balance is sufficient. ```yaml click-requirement: requirement: clicks: - ALL requirements: - type: placeholder placeholder: "%vault_eco_balance%" action: SUPERIOR_OR_EQUAL value: 100 deny: - type: message messages: - "&cYou need at least $100!" ``` -------------------------------- ### Dialogue Type Configuration Source: https://docs.groupez.dev/zmenu/configurations/dialogues Example of specifying the type of dialogue, such as 'notice'. ```yaml type: notice ``` -------------------------------- ### Granting Permissions with LuckPerms Source: https://docs.groupez.dev/zmenu/configurations/custom-commands Examples of using LuckPerms to grant permissions for specific commands like 'server.shop' and 'server.admin.menu'. ```bash # Give permission to use shop /lp group default permission set server.shop true # Admin menu for admins only /lp group admin permission set server.admin.menu true ``` -------------------------------- ### Simple Form Configuration Source: https://docs.groupez.dev/zmenu/configurations/bedrock Example configuration for a simple Bedrock form. This form includes three buttons, two with images, and defines click actions for each. ```yaml type: simple name: "Simple Form" buttons: button1: type: "bedrock_button" text: "Button 1" click-requirement: 1: success: - type: message messages: - "&aAction for button 1" button2: type: "bedrock_button" text: "Button 2" image-type: "URL" image-value: "https://github.com/GeyserMC.png?size=200" click-requirement: 1: success: - type: message messages: - "&aAction for button 2" button3: type: "bedrock_button" text: "Button 3" image-type: "PATH" image-value: "textures/i/glyph_world_template.png" click-requirement: 1: success: - type: message messages: - "&aAction for button 3" ``` -------------------------------- ### Item with Components Source: https://docs.groupez.dev/zmenu/configurations/items/item Example of an item with custom name, rarity, enchantments, and fire resistance using the component system. ```yaml item: material: DIAMOND_SWORD components: custom-name: "&6&lLegendary Sword" rarity: EPIC enchantments: sharpness: 5 fire-resistant: true ``` -------------------------------- ### LuckPerms Requirement Example Source: https://docs.groupez.dev/zmenu/supported-plugins Shows how to implement a click requirement based on player group membership using LuckPerms. ```yaml click-requirement: vip-check: clicks: - ALL requirements: - type: luckperm group: vip deny: - type: message messages: - "&cYou need VIP rank to use this!" ``` -------------------------------- ### Basic INPUT Button Configuration Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/input Example of a basic INPUT button configuration that captures text input and displays messages based on validation. ```yaml items: input-button: type: INPUT slot: 13 inputType: TEXT conditions: regex: "^[a-zA-Z0-9]*$" success-actions: - type: message messages: ["&aValid input: %input%"] error-actions: - type: message messages: ["&cInvalid input! Only alphanumeric characters allowed."] item: material: NAME_TAG name: "&a&lEnter Text" ``` -------------------------------- ### Argument Validation Example Source: https://docs.groupez.dev/zmenu/configurations/custom-commands Demonstrates defining command arguments with specific types for validation (e.g., online player, integer) and auto-completion. ```yaml arguments: - name: "player" type: online-player isRequired: true auto-completion: "@players" - name: "amount" type: integer isRequired: false auto-completion: - "1" - "10" - "64" ``` -------------------------------- ### Inventory Slot Numbering Source: https://docs.groupez.dev/zmenu/configurations/inventories/create-inventory This example visually represents the slot numbering system for inventories, starting from 0 in the top-left and increasing row by row. ```text Row 1: 0 1 2 3 4 5 6 7 8 Row 2: 9 10 11 12 13 14 15 16 17 Row 3: 18 19 20 21 22 23 24 25 26 Row 4: 27 28 29 30 31 32 33 34 35 Row 5: 36 37 38 39 40 41 42 43 44 Row 6: 45 46 47 48 49 50 51 52 53 ``` -------------------------------- ### Get Inventory by Plugin Name Source: https://docs.groupez.dev/zmenu/development/api-inventory Retrieve an inventory by its name and the name of the plugin that registered it. Includes an example for accessing the zAuctionHouse plugin's auction inventory. ```java Optional inventory = manager.getInventory("shop", "MyPlugin"); // Example: Get inventory from zAuctionHouse plugin Optional auctionInventory = manager.getInventory("auction", "zAuctionHouse"); auctionInventory.ifPresent(inv -> { manager.openInventory(player, inv); }); ``` -------------------------------- ### Register Paginate Button with NoneLoader Source: https://docs.groupez.dev/zmenu/development/api-paginate-button Use `NoneLoader` to register a paginate button, especially when it only requires a Plugin constructor. This example shows how to get the `ButtonManager` and register the button. ```java @Override public void onEnable() { MenuPlugin menuPlugin = (MenuPlugin) Bukkit.getPluginManager().getPlugin("zMenu"); if (menuPlugin != null) { ButtonManager buttonManager = menuPlugin.getButtonManager(); // Register with NoneLoader for buttons with only a Plugin constructor buttonManager.register(new NoneLoader(this, MyPaginatedButton.class, "MY_PAGINATED_BUTTON")); } } ``` -------------------------------- ### Usage of CurrencyManager Source: https://docs.groupez.dev/zmenu/development/api-player-data Demonstrates how to use the CurrencyManager class to interact with player currency. Includes examples for checking balance, adding coins, and removing coins with a check. ```java CurrencyManager currency = new CurrencyManager(menuPlugin); // Check balance int balance = currency.getCoins(player); player.sendMessage("Balance: " + balance); // Add coins currency.addCoins(player, 100); player.sendMessage("Added 100 coins!"); // Remove coins (with check) if (currency.removeCoins(player, 50)) { player.sendMessage("Spent 50 coins"); } else { player.sendMessage("Not enough coins!"); } ``` -------------------------------- ### Example Click Requirement with Permission Source: https://docs.groupez.dev/zmenu/configurations/requirements This snippet demonstrates a click requirement that checks for a specific server permission. If the permission is not met, a deny message is shown. ```yaml click-requirement: vip-requirement: clicks: - ALL requirements: - type: permission permission: "server.vip" denies: - type: message messages: - "&cYou need VIP to use this!" success: - type: message messages: - "&aWelcome, VIP!" ``` -------------------------------- ### Complete Z-Menu Example Source: https://docs.groupez.dev/zmenu/configurations/inventories/create-inventory A full Z-Menu configuration demonstrating a server menu with a title, decorative borders, interactive buttons for spawn, warps, profile, settings, and a close button. Includes sound effects and player actions. ```yaml name: "&6&lServer Menu" size: 45 enable: true fillItem: material: BLACK_STAINED_GLASS_PANE name: "&8" openActions: - type: sound sound: BLOCK_CHEST_OPEN pitch: 1.0 items: # Decorative top border top-border: slots: - 0-8 item: material: BLUE_STAINED_GLASS_PANE name: "&8" # Title title: slot: 4 item: material: NETHER_STAR name: "&6&l✦ Server Menu ✦" lore: - "" - "&7Welcome, &f%player%" - "" - "&7Choose an option below" glow: true # Spawn teleport spawn: slot: 19 item: material: RED_BED name: "&c&lSpawn" lore: - "&7Return to spawn" - "" - "&e▸ Click to teleport" sound: UI_BUTTON_CLICK actions: - type: close - type: player-command commands: - "spawn" - type: message messages: - "&aTeleporting to spawn..." # Warps menu warps: slot: 21 item: material: ENDER_PEARL name: "&5&lWarps" lore: - "&7Browse warp locations" - "" - "&e▸ Click to open" sound: UI_BUTTON_CLICK actions: - type: inventory inventory: "warps" # Player info profile: slot: 23 item: material: PLAYER_HEAD playerHead: "%player%" name: "&a&lYour Profile" lore: - "&8&m────────────────" - "" - "&7Name: &f%player%" - "&7Balance: &6$%vault_eco_balance%" - "&7Playtime: &e%zmenu_statistic_time_played%" - "" - "&8&m────────────────" # Settings settings: slot: 25 item: material: COMPARATOR name: "&e&lSettings" lore: - "&7Configure preferences" - "" - "&e▸ Click to open" sound: UI_BUTTON_CLICK actions: - type: inventory inventory: "settings" # Bottom border bottom-border: slots: - 36-44 item: material: BLUE_STAINED_GLASS_PANE name: "&8" # Close button close: slot: 40 item: material: BARRIER name: "&c&lClose Menu" lore: - "&7Close this menu" sound: UI_BUTTON_CLICK actions: - type: close ``` -------------------------------- ### Basic PaginateButton Implementation Source: https://docs.groupez.dev/zmenu/development/api-paginate-button This example shows a basic implementation of the PaginateButton class. It demonstrates how to override onRender and getPaginationSize to display paginated items and handle clicks. ```java import fr.maxlego08.menu.api.button.PaginateButton; import fr.maxlego08.menu.api.engine.InventoryEngine; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; public class MyPaginatedButton extends PaginateButton { private final MyPlugin plugin; public MyPaginatedButton(Plugin plugin) { this.plugin = (MyPlugin) plugin; } @Override public void onRender(Player player, InventoryEngine inventoryEngine) { // Get your list of items List items = getItems(player); // Use the paginate helper method paginate(items, inventoryEngine, (slot, item) -> { // Create the ItemStack for display ItemStack itemStack = createDisplayItem(item); // Add item to the inventory with click handler inventoryEngine.addItem(slot, itemStack) .setClick(event -> handleClick(player, item, event)); }); } @Override public int getPaginationSize(Player player) { // Return the total number of items to paginate return getItems(player).size(); } private List getItems(Player player) { return plugin.getItemManager().getItems(player); } private ItemStack createDisplayItem(MyItem item) { // Create and return the display ItemStack return item.toItemStack(); } private void handleClick(Player player, MyItem item, InventoryClickEvent event) { // Handle the click event player.sendMessage("You clicked on: " + item.getName()); } } ``` -------------------------------- ### HeadDatabase Custom Head Example Source: https://docs.groupez.dev/zmenu/supported-plugins Example of how to specify a custom head from the HeadDatabase plugin using its unique ID. ```yaml item: material: HEAD_DATABASE:1234 ``` -------------------------------- ### Basic YAML Configuration Example Source: https://docs.groupez.dev/zmenu/configurations/informations Illustrates a simple YAML structure for zMenu configuration, showing comments, string, number, and boolean values, as well as nested sections for item properties. ```yaml # This is a comment inventory-name: "My Inventory" # String value size: 54 # Number value enabled: true # Boolean value items: # Start of a section my-button: # Button name (key) slot: 0 # Property of my-button item: # Nested section material: DIAMOND name: "&bDiamond" ``` -------------------------------- ### Placeholder with Default Value Check Source: https://docs.groupez.dev/zmenu/configurations/player-data Example of checking for a player data key's existence and using a default value of 0 if it doesn't exist. ```yaml # In requirements, check for existence - type: placeholder placeholder: "%zmenu_player_value_coins%" action: SUPERIOR_OR_EQUAL value: 0 # Works even if key doesn't exist ``` -------------------------------- ### Local Placeholders Example Source: https://docs.groupez.dev/zmenu/configurations/global-placeholders Example of how to define and use local placeholders within an inventory file. These are specific to a single inventory. ```yaml # In inventory file local-placeholders: category: "Weapons" discount: "20%" items: header: item: name: "&6%category% Shop" lore: - "&7Sale: %discount% off!" ``` -------------------------------- ### Advanced DYNAMIC_PAGINATION with Navigation and Info Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/dynamic-pagination An advanced example demonstrating DYNAMIC_PAGINATION with player list source, custom item formatting, navigation buttons (previous/next), and page information display. ```yaml size: 54 name: "&8Online Players" items: player-list: type: DYNAMIC_PAGINATION slots: - 10-16 - 19-25 - 28-34 source: "online_players" item: material: PLAYER_HEAD player-head: "%entry_name%" name: "&a&l%entry_name%" lore: - "&7Click to view profile" actions: - type: player-command commands: - "profile %entry_name%" # Navigation previous: type: PREVIOUS slot: 48 is-permanent: true item: material: ARROW name: "&c&lPrevious" next: type: NEXT slot: 50 is-permanent: true item: material: ARROW name: "&a&lNext" # Page info info: slot: 49 is-permanent: true item: material: PAPER name: "&7Page %page%/%max_page%" ``` -------------------------------- ### Example: Default Actions for Buttons Source: https://docs.groupez.dev/zmenu/configurations/patterns Illustrates the effect of applying the 'default-actions' pattern. Buttons will play specific sounds on successful or denied clicks unless individually configured otherwise. ```yaml name: default-actions actions: - type: sound sound: ENTITY_VILLAGER_YES deny-actions: - type: sound sound: ENTITY_VILLAGER_NO ``` -------------------------------- ### Server Information Command with Sound Action Source: https://docs.groupez.dev/zmenu/configurations/custom-commands Sets up a server information command that plays a sound effect upon execution. Aliases are included. ```yaml commands: info: command: /info inventory: server_info aliases: - serverinfo - about actions: - type: sound sound: ENTITY_EXPERIENCE_ORB_PICKUP ``` -------------------------------- ### Oraxen Custom Item Example Source: https://docs.groupez.dev/zmenu/supported-plugins Example of how to specify an item from the Oraxen plugin. The material format uses the ORAXEN prefix followed by the item identifier. ```yaml item: material: ORAXEN:emerald_sword ``` -------------------------------- ### Shop System Integration Source: https://docs.groupez.dev/zmenu/development/api-inventory Demonstrates how to open various shop inventories (main, category, player-specific) using the InventoryManager. Requires a MenuPlugin instance. ```java public class ShopManager { private final MenuPlugin menuPlugin; public ShopManager(MenuPlugin menuPlugin) { this.menuPlugin = menuPlugin; } public void openShop(Player player) { InventoryManager manager = menuPlugin.getInventoryManager(); manager.getInventory("shop-main").ifPresent(inv -> { manager.openInventory(player, inv); }); } public void openCategory(Player player, String category) { InventoryManager manager = menuPlugin.getInventoryManager(); List args = Collections.singletonList(category); manager.getInventory("shop-category").ifPresent(inv -> { manager.openInventory(player, inv, 1, args); }); } public void openPlayerShop(Player viewer, Player shopOwner) { InventoryManager manager = menuPlugin.getInventoryManager(); List args = Arrays.asList( shopOwner.getName(), shopOwner.getUniqueId().toString() ); manager.getInventory("player-shop").ifPresent(inv -> { manager.openInventory(viewer, inv, 1, args); }); } } ``` -------------------------------- ### Hex Color Code Example Source: https://docs.groupez.dev/zmenu/configurations/informations Example of using Hex color codes in zMenu configurations. Colors are defined using RGB values prefixed with '#'. ```yaml name:"&#FF5555This is red 7FF55and this is green" ``` -------------------------------- ### Opening Dialog from Button Action Source: https://docs.groupez.dev/zmenu/configurations/dialogues Configures an inventory button that, when clicked, opens a dialog named 'welcome'. ```yaml items: open-dialog: slot: 13 item: material: BOOK name: "&6Open Dialog" actions: - type: dialog dialog: "welcome" ``` -------------------------------- ### Good Player Data Naming Examples Source: https://docs.groupez.dev/zmenu/configurations/player-data Examples of descriptive and conventional names for player data variables. These names clearly indicate the purpose or content of the data. ```plaintext player_coins quest_tutorial_complete settings_notifications stats_kills daily_last_claim ``` -------------------------------- ### Opening Dialog with Arguments Source: https://docs.groupez.dev/zmenu/configurations/dialogues Demonstrates how to open a dialog named 'confirmation' and pass specific arguments ('diamond_sword', '500') to it. ```yaml actions: - type: dialog dialog: "confirmation" arguments: - "diamond_sword" - "500" ``` -------------------------------- ### Bad Player Data Naming Examples Source: https://docs.groupez.dev/zmenu/configurations/player-data Examples of poor naming conventions for player data variables. These names are too short, not descriptive, or meaningless, leading to potential confusion. ```plaintext c # Too short data1 # Not descriptive x # Meaningless ``` -------------------------------- ### Complete Example: Plugin Integration Service Source: https://docs.groupez.dev/zmenu/development/api-inventory A comprehensive Java class demonstrating how to manage inventories within a plugin, including opening inventories registered by the plugin itself or by external plugins, with support for pagination and navigation history. ```java public class InventoryService { private final Plugin plugin; private final InventoryManager inventoryManager; public InventoryService(Plugin plugin, MenuPlugin menuPlugin) { this.plugin = plugin; this.inventoryManager = menuPlugin.getInventoryManager(); } /** * Opens an inventory registered by this plugin */ public void openOwnInventory(Player player, String inventoryName) { inventoryManager.getInventory(plugin, inventoryName).ifPresent(inv -> { inventoryManager.openInventory(player, inv); }); } /** * Opens an inventory registered by another plugin */ public void openExternalInventory(Player player, String pluginName, String inventoryName) { inventoryManager.getInventory(inventoryName, pluginName).ifPresent(inv -> { inventoryManager.openInventory(player, inv); }); } /** * Opens an inventory with pagination support */ public void openInventoryAtPage(Player player, String inventoryName, int page) { inventoryManager.getInventory(plugin, inventoryName).ifPresent(inv -> { inventoryManager.openInventory(player, inv, page); }); } /** * Opens an inventory preserving the navigation history * Allows players to go back to previous inventories */ public void openWithHistory(Player player, String inventoryName, int page) { inventoryManager.getInventory(plugin, inventoryName).ifPresent(inv -> { inventoryManager.openInventoryWithOldInventories(player, inv, page); }); } } ``` -------------------------------- ### Multi-Action Dialog Example Source: https://docs.groupez.dev/zmenu/configurations/dialogues This configuration defines a dialog with multiple action buttons, including teleporting to spawn, shop, PvP arena, and home. It specifies the layout, button text, tooltips, and the commands to execute upon clicking each button. ```yaml name: "&6&lTeleport Menu" external_title: "Teleport" type: multi_action can-close-with-escape: true after_action: CLOSE number-of-columns: 2 body: header: type: plain_message messages: - "&7Select a destination:" width: 300 multi-actions: spawn: text: "&a&lSpawn" tooltip: "&7Teleport to spawn" width: 150 actions: 1: success: - type: close - type: player-command commands: - "spawn" - type: message messages: - "&aTeleporting to spawn..." shop: text: "&e&lShop" tooltip: "&7Visit the shop" width: 150 actions: 1: success: - type: close - type: player-command commands: - "warp shop" pvp: text: "&c&lPvP Arena" tooltip: "&7Enter the PvP arena" width: 150 actions: 1: success: - type: close - type: player-command commands: - "warp pvp" home: text: "&b&lHome" tooltip: "&7Teleport home" width: 150 actions: 1: success: - type: close - type: player-command commands: - "home" ``` -------------------------------- ### Opening Inventory using Actions (Alternative) Source: https://docs.groupez.dev/zmenu/configurations/buttons/types/inventory Demonstrates opening the 'shop' inventory using the 'inventory' action with a 'NONE' button type. This is functionally equivalent to the INVENTORY button type. ```yaml items: open-shop: slot: 13 item: material: GOLD_INGOT name: "&e&lShop" actions: - type: inventory inventory: "shop" ``` -------------------------------- ### Get InventoryManager Instance Source: https://docs.groupez.dev/zmenu/development/api-inventory Obtain the InventoryManager instance, which is the primary interface for inventory operations. ```java InventoryManager manager = menuPlugin.getInventoryManager(); ``` -------------------------------- ### Download and Reload Expansions Source: https://docs.groupez.dev/zmenu/configurations/placeholders Download missing PlaceholderAPI expansions using `/papi ecloud download ` and then reload the server with `/papi reload`. ```minecraft-command /papi ecloud download /papi reload ``` -------------------------------- ### Item with Enchants Source: https://docs.groupez.dev/zmenu/configurations/items/item Example of adding enchantments to an item using the 'enchants' key, which is an alias for 'enchantments'. ```yaml item: material: DIAMOND_SWORD enchants: - SHARPNESS,5 - UNBREAKING,3 ``` -------------------------------- ### Define Server Information Placeholders Source: https://docs.groupez.dev/zmenu/configurations/global-placeholders Configure global placeholders for server name, IP, Discord, website, owner, and founding year. ```yaml # global-placeholders.yml server-name: "CraftWorld" server-ip: "play.craftworld.net" discord: "discord.gg/craftworld" website: "https://craftworld.net" owner: "Notch" founded: "2020" ``` -------------------------------- ### Dialogue Name Configuration Source: https://docs.groupez.dev/zmenu/configurations/dialogues Example of setting the internal name for a dialogue, which can include color codes. ```yaml name: "&6&lWelcome Dialog" ``` -------------------------------- ### Get All Inventories Source: https://docs.groupez.dev/zmenu/development/api-inventory Retrieves all currently loaded inventories. This method returns a Collection of all Inventory objects. ```APIDOC ## Get All Inventories ### Description Retrieves all currently loaded inventories. This method returns a Collection of all Inventory objects. ### Method `getInventories()` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```java Collection allInventories = manager.getInventories(); ``` ### Response #### Success Response - `Collection`: A collection containing all loaded Inventory objects. ```