Interface MenuBackgroundCondition
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A condition an add-on adds to the
when of menu background rules in guis.yml.
Server owners write it under the add-on's namespace, namespace:name (see
nameOf(Plugin, String)), anywhere a built-in condition such as permission may
stand. For a condition registered as myranks:rank:
- when: { myranks:rank: gold } argument "gold"
- when: { myranks:rank: [gold, "!trial"] } every one must hold; "!" means "not"
- when: { myranks:rank: true } argument "" (false asks for the opposite)
- when: "myranks:rank(gold) and page > 1" argument "gold"; several are all tested
- when: "not myranks:rank" argument ""
The argument is what the owner wrote, trimmed; what it means is up to the add-on. A condition that throws counts as false and is reported in the console once.
- Since:
- 1.15.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classHolds the name pattern, which an interface cannot keep as a private constant. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringThe name server owners write for a condition or value a plugin registers: the plugin's name in lowercase, with every character outsidea-z,0-9,_and-replaced by_, then a colon and the name.booleantest(@NotNull MenuConditionContext context, @NotNull String argument) Tests the condition for one viewer's menu.
-
Method Details
-
test
Tests the condition for one viewer's menu. Runs on the main thread.- Parameters:
context- the viewer, their menu and the momentargument- what the owner wrote after the condition's name, empty when nothing- Returns:
- whether the condition holds
-
nameOf
@NotNull static @NotNull String nameOf(@NotNull @NotNull org.bukkit.plugin.Plugin owner, @NotNull @NotNull String name) The name server owners write for a condition or value a plugin registers: the plugin's name in lowercase, with every character outsidea-z,0-9,_and-replaced by_, then a colon and the name.- Parameters:
owner- the registering pluginname- the condition's name within the plugin, usinga-z,0-9,_and-; case is ignored- Returns:
- the name as written in
guis.yml, such asmyranks:rank - Throws:
IllegalArgumentException- when the name uses other characters
-