Skip to content

Rules

Menu author

A rule is a check before performing some actions. The result of this check influences what actions will be performed.

Rules has simple format. Example:

rules {
permission: "some.perm"
}

You can specify one or several rules, similar to activators and actions. Every new rule must be on the new line. For example:

rules {
permission: "some.perm"
group: "default"
money: 3000
}

In this example, we check a player for permission “some.perm”, a group “default” and money amount in 3000. All next actions will be executed only if player matches all of these rules.

NameData typeDescription
permissionStrings listPlayer has a permission node
worldStringPlayer is in the named world
gamemodeStringPlayer’s gamemode matches
groupStrings listPlayer is in a LuckPerms group
moneyNumber or ObjectPlayer has at least N currency. Object form { amount, provider } lets you pin a specific economy provider — see Provider selection.
levelNumberPlayer has at least N levels
xpNumberPlayer has at least N XP points
healthNumberPlayer has at least N HP
foodLevelNumberPlayer has at least N food level
chanceNumberRandom check at N percent
onlineNumberAt least N players online
playerIsOnlineStringA specific player is online
inventoryItemsObjects listPlayer has the listed items in inventory
heldItemObjectItem in main hand matches
freeSlotNumberInventory has a free slot (or specific slot is free)
freeSlotCountNumberInventory has at least N free slots
existVarString or ObjectA global variable exists
existVarpStringA per-player variable exists
placedItemObjectA drag-and-drop slot has the expected item
WorldGuard
regionStrings listPlayer is inside a WorldGuard region
BungeeCord
bungeeOnlineObjectA BungeeCord server has enough players
bungeeIsOnlineStringA BungeeCord server is online
Complex rules
ifObjects listCompare placeholders with text or numeric values
jsStringRun a JavaScript expression and use its result
Special rules
andObjects listLogical AND wrapper
orObjects listLogical OR wrapper
oneofObjects listStops on the first matching rule
playerScopeObjectRe-evaluate rules against a different player

Rule to check player’s inventory for some items. This is an objects list, where each object is an item. Items has same format as anywhere in AM. Example:

inventoryItems: [
{
material: CAKE
amount: 5
},
{
material: STONE
amount: 2
}
]

You can also use it as a single object. Example:

inventoryItems {
material: CAKE
amount: 5
}

If you add slot parameter, this rule will check item in specified slot or slots:

inventoryItems {
slot: 0
material: CAKE
amount: 5
}

The rule above will be true for player if it has at least 5 cakes in slot 0. You can also use other slot formats, for example:

inventoryItems {
slot: "0-8"
material: CAKE
amount: 5
}

The rule above will be true for player if it has at least 5 cakes in each slot 0, 1, 2, ..., 8

Rule to check a held item.

heldItem {
material: CAKE
amount: 5
}

Rules to check is there exists some variable.

For global variables:

existVar: "global_var_name"

For personal variables:

existVarp: "personal_var_name"

Rule existVar also has legacy format. It can be specified as object with variable name and optional name of player - variable owner.

existVar {
player: "Peter" // Specify only if variable is personal. Optional parameter
name: "name" // Name of the variable. Required parameter.
}
  • name - Variable name.

  • player - [Optional] Specify if you need to check personal variable.

However, we recommend you to use brief format of existVar rule where this possible.

Rule to check players count on some BungeeCord server. Example:

bungeeOnline {
server: "lobby"
online: 20
}
  • server - BungeeCord server name.

  • online - Required players count.

Rule to compare some data (for example, placeholder from PAPI) with another data.

The if rule has two formats: modern and legacy. Use the modern form — the legacy form is kept only so old menus keep parsing.

This format similar to js rule. But unlike js, modern if works much faster, around 8-10 times. Example:

if: "%player_name% == Notch"

Here we compare placeholder with some value. Modern if has no math expressions, only logical. Below are all logical operators which you can use for your expressions.

OperatorExampleMeansPriority
>%player_level% > 5More3
<%player_level% < 8Less3
>=%player_level% >= 5More or equals3
<=%player_level% <= 8Less or equals3
==%player_level% == 9Equals2
!=%player_level% != 9Not equals2
===%player_name% === nOtChEquals ignore case2
!==%player_name% !== nOtChNot equals ignore case2
&&%player_level% > 5 && %player_name% == NotchAnd1
||%player_level% > 5 || %player_name% == NotchOr0

Unlike js rule, inside if you don’t need to use quotes ('', "") to define strings. There are also logical brackets () to define logical groups and increase priority of some operations. Example:

if: "(%player_lvl% == 5 || %player_lvl% == 10) && (%player_name% == Notch || %player_name% == Nanit)"

This expression will return true if player has level 5 or 10 AND if has username “Notch” or “Nanit”.

If you need math operations or more complex conditions, then you can use js rule. But if not, we recommend use modern if rule to speed up you menus.

Example:

if {
param: "%player_name%"
equals: [
"Notch",
"DeadMouse"
]
equalsIgnoreCase: [
"notch",
"deadmouse"
]
contains: [
"dead",
"tch"
]
less: 6
more: 2
}

Parameter param is required. All other are optional.

  • param - The parameter which you compare (%player_name% is a placeholder which replaces to player name who opened menu).

  • equals - Check parameter with list of strings. Case sensitivity.

  • equalsIgnoreCase - Check parameter with list of strings. Case insensitivity

  • contains - Check parameter to contains one of the specified substring.

  • less - Does the parameter less than the specified number. For numeric parameters only.

  • more - Does the parameter greater than the specified number For numeric parameters only.

The plugin allows you to use JavaScript code. Code inside must always return the result - true or false. If the code returns something else, the plugin will suppose this is a false. This rule can be used as a replacement for the if rule because of its greater versatility. But you should understand that interpreting JavaScript will take longer than the if rule.

The js rule supports placeholders. This will allow you to compare them, and manipulate them using JavaScript syntax. Example:

rules {
  js: "'%player_name%'.length < 5"
}

If you need to check another player, you can use special rules wrapper called playerScope. Example with item display rules:

{
slot: 0
material: cake
rules {
playerScope {
name: "%player_name_placeholder%"
rules {
permission: "perm.name"
}
}
}
}

The rules inside rules block will be executed for player who found by name, entered in name field. In our case, item will be shown if player found by placeholder has perm.name permission.