You already know how to [How to create menu](How to create menu), so here you will learn in detail about the menu structure and other useful features of the plugin.
## <a name="file">Menu file</a>
Each menu can be put in a single menu as well as one file may contain endless amount of menus.
#### <a name="solo">Single menu in a single file</a>
```hocon
title:"&8Menu"// Menu title
size:6// Vertical size of the menu (number of rows)
activators{// Actions which let you to open the menu
Menu structure may seem difficult at first sight, but you don't have to be afraid of it, as you will move forward through the wiki you will learn how work each part of the plugin.
#### <a name="multi">Multiple menus in a single file</a>
---
If you are making a small menu, it may have sense to do it in a single file with other menus. To do this, the plugin has a design that allows you to create several menus in a single file at once. In this case, the menu name will be considered the name of the block in which it is created. Here is an example:
```hocon
menus{
my_awesome_menu{// Menu name (unique)
title:"My menu"
size:6
items:[
...
]
}
my_another_menu{
title:"My another menu"
size:1
items:[
...
]
}
}
```
All menus listed in the main block called `menus`. In the example above ypou can see 2 separate menus in the same file.
## <a name="menuVar">Menu settings</a>
To create a menu whether in a separate file or in a single file you need to configure its parameters. The table below demonstrates all the parameters and their usage.
| activators | [Object](Data types#object) | {-No-} | [Actions](Actions) to open a menu |
| rules | [Object](Data types#object)/[Object list](Data types#list) | {-No-} | [Rules](Rules) to open a menu. If one of those is **false** then menu won't open |
| irules | [Object](Data types#object)/[Object list](Data types#list) | {-No-} | Inverse [Rules](Rules) to open a menu. If one of those is **true** then menu won't open. It can be combined with `rules` to make specific logic. |
| openActions | [Object](Data types#object) | {-No-} | [Actions](Actions), that perform **after** the menu opens |
| denyActions | [Object](Data types#object) | {-No-} | [Actions](Actions), that perform if atleast **one** rule is false |
| closeActions | [Object](Data types#object) | {-No-} | [Actions](Actions), that perform **after** the menu closes |
| updateInterval | Integer | {-No-} | Sets the menu update interval in ticks |
A bit more detailed about the `updateInterval` setting. If you want to create a menu that will automatically update including items, placeholders and any other dynamic data, you can specify the interval for updating the menu.
```hocon
title:"Dynamic menu"
size:1
updateInterval:40
items:[
{
slot:0
material:CAKE
name:"Players: %server_players%"
}
]
```
The menu above will be updated every 2 seconds. Along with this, the button that shows the number of players on the server will be updated along with the placeholder `%server_players%`.
In the example above was used the default [placeholder](Placeholders).
## <a name="buttons">Menu buttons</a>
The button in the menu is an ordinary [item] (Item format) with advanced functionality. Below are all the parameters that can be specified in addition to the standard parameters of an item.
| [slot](Item format#slot) | Integer, Object, Text| Sets the position of an item | {+Yes+} |
| [rules](#btnRules) | [Object list](Data types#list) | [Rules](Rules) to display buttons in the menu | {-No-} |
| [irules](#btnRules) | [Object list](Data types#list) | [Rules](Rules) to display buttons in the menu, working exactly the opposite | {-No-} |
| [mrules](#btnRules) | [Object list](Data types#list) | Additional [rules](Rules) block, existing only inside the button. These rules have no effect on whether the button is displayed. They are needed only for independent checks and performing actions. | {-No-} |
| [imrules](#btnRules) | [Object list](Data types#list) | Additional **inverted**[rules](Rules) block, existing only inside the button. These rules have no effect on whether the button is displayed. They are needed only for independent checks and performing actions. | {-No-} |
| [click](#btnClicks) | [Object](Data types#list) | It contains actions on a click as well as a description of actions for different types of clicks | {-No-} |
As you can see, only the `slot` argument is required for the button because the item must be in a specific slot.
#### <a name="btnRules">Display rules</a>
Any button can be displayed without any rules. But you can also set rules for displaying a button in the inventory menu. Such rules will limit the output of some buttons if the player does not comply with the rules. To do this you can specify two rule blocks in the item description: `rules` and` iRules`.
```hocon
items:[
{
slot:0
material:IRON_SWORD
},
{
slot:0
material:DIAMOND_SWORD
rules{
permission:"some.perm"
}
},
]
```
In this example, the menu has two items. The first (Iron Sword) will be displayed in slot 0 in any case. The second (Diamond Sword) will be displayed in slot 0 and will replace the first item only if the player has the permission "some.perm".
Let's take a look at a similar example, but using inverted iRules.
```hocon
items:[
{
slot:0
material:IRON_SWORD
},
{
slot:0
material:DIAMOND_SWORD
iRules{
permission:"some.perm"
}
},
]
```
In this example, the menu contains the same items. The first one will still be displayed in slot 0. The second one will be displayed in slot 0 and will replace the first item only if the player **does not** have the "some.perm" permission.
The `rules` and` iRules` blocks can be combined, which is writing both in the same item. In this case, the item will be removed if the player **complies with** the rules described in `rules` and at the same time **does not comply with** the rules described by `iRules`. For example:
```hocon
items:[
{
slot:0
material:DIAMOND_SWORD
rules{
permission:"some.perm"
}
iRules{
permission:"another.perm"
}
},
]
```
In this example, the diamond sword will appear on the menu only if the player has the permission "some.perm" and the permission "another.perm" is missing.
#### <a name="btnClicks">Click processing</a>
Almost any menu is useless without processing button clicks. The plugin provides a convenient system for processing clicks on buttons.
So, let's take a look at the `click` block.
```hocon
items:[
{
slot:0
material:DIAMOND_SWORD
click{
left{
message:"Hello"
}
}
},
]
```
Inside the `click` block, the left block is specified. This is nothing more than the type of click that triggers the actions inside the block. Inside the block responsible for the type of click, you can describe the same [actions](Actions) and [rules](Rules) as in the click block itself.
All types of clicks you can find [here](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/ClickType.html). We will describe the main working on all versions:
| **Click type** | **Description** |
| --------------- | ----------------- |
| LEFT | LMB click |
| RIGHT | RMB click |
| MIDDLE | MMB click |
| SHIFT_LEFT | LMB with pressed Shift |
| SHIFT_RIGHT | RMB with pressed Shift |
| DOUBLE_CLICK | Double LMB click |
Any of these types can be used in the `click` block either individually or together with other types in the same block.
```hocon
items:[
{
slot:0
material:STONE
click{
message:"That was the click"// Will be displayed on any click
right{
message:"That one was RMB click"// Will be displayed on RMB click
}
middle{
message:"Adn this one was MMB click"// Will be displayed on MMB click
}
}
}
]
```
## <a name="templates">Templates</a>
Thanks to the flexible HOCON format you can create templates for anything. A template can be any argument, object, list, etc. Templates can be set both inside the menu file, and you can put all the templates in a separate file, for example `tamplates.conf`. In order to tell the plugin that `templates.conf` is a file with templates you must specify in the first line `# invisible`, otherwise `templates.conf` will be detected by the plugin as a menu file.
> ⚠️ **Important**: All the examples below describe only some of the features that HOCON provides. More details can be found in [official documentation] (https://github.com/lightbend/config/blob/master/HOCON.md)
For example, in each of the bunch of menus the "Close menu" button has the same look and settings.
What happens when the plugin loads the entire menu? While reading a file, it reaches the line where the special placeholder `${closeButton}` is detected, **the content** of the `closeButton` block will be virtually loaded instead of the placeholder. Physically, the file itself will not change.
#### <a name="templatesConf">Templates file</a>
The example above is perfect if the template will be used only inside one menu file. And if there are a lot of files with different menus, what then? In this case, the template file will help. To do this, create a file in the `menus` folder with any name, for example `templates.conf`. In this file you can describe any blocks and parameters in any order for subsequent insertion into the menu file.
> ⚠️ ** Important **: To make it clear to the plugin that this file is used for storing templates you need to specify `#invisible` at the beginning of the file
include required(file("./plugins/AbstractMenus/menus/templates.conf"))
title: "&8Menu"
size: 6
items: [
${closeButton}
]
```
Now, when reading the **menu.conf** file the plugin will come across a line with the `include` directive and the first thing to do is virtually insert the entire contents of the **templates.conf** file into the place where the directive itself was located. As with placeholders, the file will not physically change.
As a result, the placeholder `${closeButton}` will be replaced with the content of the `closeButton` block, which is safely "located" in the menu file.
HOCON also allows you to overwrite any template data. This can come in handy if you need to change only one item setting in the template, for example `slot`.
Example: `closeButton` _ (item description above)_ has `slot: "5.5". Not all menus may need to place a button in this slot. To do this, you can overwrite the `slot` setting from the `closeButton` button template.