Module: command_state
Overview
This module allows defining a state using predicate commands.
Using this defined state, you can:
-
Define commands to be executed when a player
entersorleavesthisstate. -
Check whether a player is currently in the
state. -
Display
placeholdersrelevant to thestate.
Color Boxes
◉ Define a state using predicate commands.
A state is composed by predicate commands.
You can define a state called has-iron-and-gold, with the following predicate commands:
-
has-item? %player:name% minecraft:iron_ingot 16 -
has-item? %player:name% minecraft:gold_ingot 8
◉ Integrate with luckperms's temporary permission.
Assign a temporary permission using /lp group default permission settemp fuji.permission.fly true 10s
Then define a state to check whether a player has specified temporary permission.
This state can be called can-use-fly-command with the following predicate commands:
has-perm? %player:name% fuji.permission.fly
Last, you can define commands to be executed when a player leave this state.
For example, define commands to turn off the flying while the player leaves the state.
◉ Check the value of a state of a player.
Issue: /command-state info Steve
Besides that, the /is-in-state? <player> <state-id> can be used as a predicate command.
Configurations
The following JSON content is provided for reference only. It must NOT be copied directly into the configuration directory, as it does not represent valid JSON syntax.
- File Name:
command-state-data.json - File Content:
Click to see the default content...
{
"player_states_map": {}
}
- File Name:
config.json - File Content:
Click to see the default content...
{
"state_descriptors": [
{
"enable": true,
"id": "is-in-overworld"
/* The `predicate commands` used to define this `state`. */,
"definition": {
"predicate_commands": [
"is-in-world? %player:name% minecraft:overworld"
]
}
/* The intervals to `check` and `update` the `status` of this `state` for online players. */,
"update_interval_seconds": 3,
"events": {
"on_enter_this_state_commands": [
"send-message %player:name% <green>You entered the overworld dimension."
],
"on_leave_this_state_commands": [
"send-message %player:name% <green>You left the overworld dimension."
]
}
},
{
"enable": true,
"id": "has-iron-and-gold"
/* The `predicate commands` used to define this `state`. */,
"definition": {
"predicate_commands": [
"has-item? %player:name% minecraft:iron_ingot 16",
"has-item? %player:name% minecraft:gold_ingot 8"
]
}
/* The intervals to `check` and `update` the `status` of this `state` for online players. */,
"update_interval_seconds": 3,
"events": {
"on_enter_this_state_commands": [
"send-message %player:name% <green>You have `iron_ingot x 16` and `gold_ingot x 8`."
],
"on_leave_this_state_commands": [
"send-message %player:name% <green>You don't have `iron_ingot x 16` and `gold_ingot x 8`."
]
}
},
{
"enable": true,
"id": "can-use-fly-command"
/* The `predicate commands` used to define this `state`. */,
"definition": {
"predicate_commands": [
"has-perm? %player:name% fuji.permission.fly"
]
}
/* The intervals to `check` and `update` the `status` of this `state` for online players. */,
"update_interval_seconds": 3,
"events": {
"on_enter_this_state_commands": [
"send-message %player:name% <green>You have gained access to `/fly` command."
],
"on_leave_this_state_commands": [
"send-message %player:name% <red>You temporary `/fly` command access has expired.",
"run as fake-op %player:name% fly false"
]
}
}
]
}
Jobs
-
Job Name:
ConfigurationHandlerWriteStorageJob -
Document: This
jobis used towrite datafrommemoryintostorage.NOTE: If you modify the
fileindisk, then you need to issue/fuji reloadas soon as possible.NOTE: The
diskwill beoverriddenwhenfirethis job.
-
Job Name:
CommandStateAutoUpdaterJob -
Document: This
jobis used tocheckandupdatethe value of all the definedstatesfor all online players.When fired, its effect is equivalent to running the
/command-state update-allcommand.
Commands
-
Command Syntax:
/command-state info <ServerPlayerEntity player> -
Document: Display the value of all
statesof the specified player. -
Can be executed by console:
false -
Required Level Permission:
4 -
Required String Permission:
null
-
Command Syntax:
/command-state list -
Document: List all defined
states. -
Can be executed by console:
true -
Required Level Permission:
4 -
Required String Permission:
null
-
Command Syntax:
/command-state update <StateDescriptor state> -
Document: Update the specified
statefor online players. -
Can be executed by console:
true -
Required Level Permission:
4 -
Required String Permission:
null
-
Command Syntax:
/command-state update-all -
Document: Update all defined
statesfor online players. -
Can be executed by console:
true -
Required Level Permission:
4 -
Required String Permission:
null
-
Command Syntax:
/is-in-state? <ServerPlayerEntity player> <StateDescriptor state> -
Document: Returns whether the specified
statevalue for the player is currentlytrue. -
Can be executed by console:
true -
Required Level Permission:
4 -
Required String Permission:
null
Placeholders
-
Placeholder Name:
fuji:is_in_state -
Document: Returns the value of specified
stateof the player.Example:
%fuji:is_in_state is-in-overworld%
Argument Types
- Argument Type Name:
[state-id] - Argument Type Class:
[StateDescriptor]