Templates
Guide to templates
The templates section in a menu file is used for items with a similar layout that appear multiple times in the same menu. Each instance of a template is differentiated by its context, a data type specified by the plugin providing the menu. Since templates depend on behavior implemented through a plugin's code, custom templates cannot be created.
Contexts
Each context has a string key that can be used to customize the appearance of specific contexts and override the default. In the contexts
section of a template, each child section must be a valid context name. Within the context name section, keys such as material
, display_name
, lore
, and pos
can be used to override the defaults.
Here is an example showing the skill template from AuraSkills:
Groups
Instead of a fixed pos
value, there is a group system that allows contexts to have their pos
generated dynamically based on the other contexts within a group. Essentially, a group is a rectangular box where items are placed into. A group is created in the groups.[name]
section, where [name
] is the name of the group.
In the example, the group is named lower
, with the following available keys defined:
start
- The starting slot position of the group, which is the top left corner of the box. Can be either inrow,column
format or a single numberslot
format.end
- The ending slot position of the group, which is the bottom right corner of the box. Can be either inrow,column
format or a single numberslot
format.align
- The alignment type used to determine where to place items. Can becenter
,left
, orright
. To determine where items are placed, the slots from start to end are ordered from left to right, then top to bottom. When align iscenter
, items will be placed so that the number of empty slots is even (or close to it) at the start and end of the group. Forleft
align, items will be filled from start so that the context with the lowestorder
is on thestart
slot. Forright
align, the context with the highestorder
will be on theend
slot.
Adding contexts to groups
Once you create a group, you have to add contexts to the group for it to work.
In a context section like stat
in the example above, the following keys are used instead of specifying a pos
:
group
- The name of the group to put the context in. This must be exactly the same as the name of the section ingroups
that the group was created.order
- An integer that defines the order number of the context. Contexts with lower orders will be placed to the left or above contexts with higher orders in the same group. If two contexts have the same order number, the order between the two is indeterminate.
When using setting a group
and order
in a context, do not specify a pos
.
Last updated