Menu Configuration
About 924 wordsAbout 3 min
MyCompany keeps menu layout and menu text in two different places:
plugins/MyCompany/menu/<menu id>.yml— inventory size, item icons and slotsplugins/MyCompany/lang/<language>.yml— every title, item name and lore line
Two rules apply to every menu file:
- Menu text is configured in the language file, never in the menu file. The menu file only says which item is shown and where.
- Menu files are open-ended. A key under
itemsis just an item. Add any item, give it amaterialand a slot, and add its text to the language file. Extra items do not need a function; they can be decoration or notes.
File structure
size: 45
items:
# special filler item, explained below
default:
material: BLACK_STAINED_GLASS_PANE
user_info:
material: PLAYER_HEAD;%player%
slot: 3
company_info:
material: DIAMOND
slot: 4
balance:
material: GOLD_INGOT
slot: 5| Key | Description |
|---|---|
size | Inventory size. Must be a multiple of 9, from 9 to 54. |
items | Required section. Every key below it becomes one menu item. |
default | Special item: skipped when the menu is drawn and used to fill every empty slot. Its text is not read from the language file. |
material | Required for every item. A Bukkit material name. An invalid name becomes AIR, and the item is invisible. |
slot | A single slot number. |
slots | A list of slot numbers. Used when slot is not set, for example to draw a frame on several slots. |
options | Optional section for menu-specific numbers, such as items per page. |
An item is only drawn when it has at least one slot. A key with a material but no slot or slots is loaded and then ignored.
Text paths
The language path is built from the menu id and the item id:
| Text | Language path |
|---|---|
| Menu title | menu.<menu id>.title |
| Item name | menu.<menu id>.items.<item id>.display_name |
| Item lore | menu.<menu id>.items.<item id>.lore |
| Click hint (optional) | menu.<menu id>.actions.<action>.<click> |
For example, menu/main.yml with the item balance uses:
menu:
main:
title: '&aMenu of &b%company%'
items:
balance:
display_name: '&aBalance'
lore:
- ''
- '&7The company has &e$%cash% &7currently.'
- ''Notes:
- Color codes use
&, for example&a,&cand&7. Hex colors use&#RRGGBB. - Menu ids and item ids are case-sensitive, and the language path must use the same spelling.
- The menu code passes placeholders such as
%company%,%player%,%cash%or%position%. Keep the placeholders that already exist in a line. - A lore line containing
#remove#is hidden. This is used by click-hint lines that only apply in some situations. - The
display_namekey uses an underscore, notdisplay-name.
Add a decorative item
Adding an item without a function takes two edits.
In the menu file:
items:
info_note:
material: PAPER
slot: 40In the language file:
menu:
main:
items:
info_note:
display_name: '&eHow to earn money'
lore:
- '&7Complete employee orders and'
- '&7create chestshops.'The item now appears in slot 40 with the configured text. Its id (info_note) does not match any action in the menu code, so clicking it has no configured effect. This is the simplest way to add decoration, separators or a short instruction block without changing any code.
If you want an item to cover several slots, use slots instead of slot:
items:
border:
material: GRAY_STAINED_GLASS_PANE
slots: [0, 1, 2, 3, 4, 5, 6, 7, 8]A player head can use the PLAYER_HEAD;<name> form:
items:
head:
material: PLAYER_HEAD;%player%
slot: 10Page options
List menus read their page size from options:
| Menu | Option |
|---|---|
position, position_list | position-per-page |
focus | expertise-per-page |
focus_list | focus-per-page |
personnel | personnel-per-page |
player_list | player-per-page |
orders | order-per-page |
area_list, area_rent_market, area_sale_market | area-per-page |
position_permission_list | permission-per-page |
Keep the value small enough that the entries fit in the slots left free by the buttons.
Menu files
The plugin loads a fixed list of menu files. Adding a new .yml file does not create a new menu; use one of these ids:
| File | Contents |
|---|---|
main | Main company menu |
found | Company creation screen |
confirmation | Confirmation dialog |
personnel | Company personnel list |
player_list | Online player list for hiring |
position, position_list, position_permission_list | Position management |
chestshop | Chestshop menu |
internal_store | Internal store |
orders | Employee orders |
focus, focus_list | Focus and expertise menus |
areas, area_list | Company area menus |
area_trade_market, area_rent_market, area_sale_market | Area markets |
Applying changes
/myc reloadreloads the language file and the menu files, including new items and changed slots.menus.ymlis different: it only stores the global no-permission icon (global.no-perm) and is read at startup. Restart the server after editing it.- Menu files that are missing are generated again from the plugin jar. Existing files are never overwritten by an update.
Troubleshooting
| Symptom | Cause |
|---|---|
| The menu does not open, or the console shows an error | size is missing or is not a multiple of 9 between 9 and 54, or an item slot is outside size. |
| An item does not appear | The item has no slot or slots, or the material is invalid and became AIR. |
| An item has no text | The language path does not match the menu id and item id, or the key is spelled differently. |
The title says Please update the language file. | menu.<menu id>.title is missing. |
| A new menu file is ignored | Only the built-in menu ids are loaded. Add the item to an existing menu file instead. |
| Changes are not applied | Run /myc reload; for menus.yml, restart the server. |