-
-
Notifications
You must be signed in to change notification settings - Fork 0
PLUGIN Click Actions
NpcPlugin lets you build action chains that run when players click an NPC.
- Remove an action: middle-click an existing action
- Add actions quickly: shift-click an action type to append it
- Reorder / insert: pick up an action type onto your cursor and click a slot
Some action types (and parts of the editor) accept expressions.
NpcPlugin supports numeric variables using $...:
-
$<name>- Searches variables in this order:
- local
- instance
- global
- Searches variables in this order:
$local.<name>$instance.<name>$global.<name>
If a variable is missing or cannot be read, it is treated as 0.
These variables exist for every click-action execution (they do not require SetVariable):
-
$self.rightClick/$self.right_click-
1if the current action execution was triggered by a right click, else0
-
-
$self.leftClick/$self.left_click-
1if the current action execution was triggered by a left click, else0
-
-
$self.sneaking-
1if the player is sneaking, else0
-
-
$self.flying-
1if the player is sneaking, else0
-
-
$self.op-
1if the player is sneaking, else0
-
-
$loop.index- Current loop index (only meaningful inside
Loopactions)
- Current loop index (only meaningful inside
Runs a command as the clicking player.
-
Input can be with or without leading
/(stored as/...) -
Supports variables/expressions via the action system (see
SetVariable+ expressions) -
Replaces placeholders:
-
{player}/%player%/<player> -
{player_name}/%player_name%/<player_name>
If command-checking is enabled, the editor validates syntax before saving.
Examples:
msg {player} Hello!
msg {player} You have $coins coins
Sends the clicking player to a BungeeCord server.
- Uses the
BungeeCordplugin message channel - The stored server name can also contain variables
Pauses the chain before continuing.
You can switch between two modes in the editor:
- Left/Right click to adjust the time
- Shift+Left/Shift+Right for bigger steps
- Range is clamped (min
0.05s, max600s)
Instead of waiting for time, the chain waits until a command is triggered:
-
Waitstores a name (string) - The chain continues only after an admin runs:
/npc wait <player> <name> [values...]
If [values...] are provided, they are exposed to the next actions as local variables:
-
<name>[0],<name>[1], ... (numeric values; invalid numbers become0.0)
In addition to /npc wait ..., the wait can also be resumed via custom clickable actions.
NpcPlugin registers a handler for custom click actions with the namespace npc:
- Action id:
npc:<name> - Payload: JSON object
All JSON entries that are numeric are mapped to variables for the next actions:
-
<name>[<jsonKey>]=<jsonValue>
Example (conceptual):
- Wait action name:
minigame - Click action id:
npc:minigame - Payload:
{
"players": 3,
"max_players": 12
}This will resume the chain and make the following variables available:
$minigame[players] = 3$minigame[max_players] = 12
/tellraw @p {"click_event":{"action":"custom","id":"npc:minigame","payload":{"players":3,"max_players":12}},"text":"Test"}
Plays an animation on the NPC for the clicking player.
- Left click: next animation
- Right click: previous animation
Makes the NPC walk along a saved path.
Configuration:
- Path name (must exist; must be in the same world)
- Speed (
0.01to1.0) - For all: if enabled, all viewers see the NPC walking
- Change real location: if enabled, the NPC’s real location is updated while walking
When the path finishes, the chain continues automatically.
Sets a numeric variable.
Configuration:
- Type:
- Local: stored per-player (PersistentDataContainer)
- Instance: stored on the NPC (custom data)
- Global: stored server-wide (saved to
global-variables.yml)
- Name: must match
^[a-zA-Z_][a-zA-Z0-9_]*$ - Value: an expression
If the value is missing, the action does nothing (admins get a warning).
Examples:
- Type: Global
- Name:
coins - Value:
$global.coins + 10
- Type: Local
- Name:
clicks - Value:
$local.clicks + 1
Then you can use it in commands:
msg {player} Clicks: $local.clicks
Runs a sub-chain only if its expression is true.
- You edit the sub-chain like a normal action list
- The condition expression is edited via the "value" item
Examples:
Condition value:
$self.sneaking == 1
Sub-chain example:
Command: msg {player} You are sneaking!
Condition value:
$global.coins >= 100
Sub-chain example:
Command: msg {player} You have enough coins.
Repeats a sub-chain.
There are two loop types:
- Repeats while the expression is
true
- Repeats with an integer loop index
- Configurable values:
- Start (optional; default
0) - End (required)
- Step (optional; default
1)
- Start (optional; default
You can change the loop type by Shift-clicking the action.
Examples:
- End value:
4
Sub-chain example (index is available as $loop.index):
Command: msg {player} Loop index: $loop.index
Opens a special editor that lets you apply NPC options as an action.
This is mainly used to change how the NPC looks/behaves for:
- Only the clicking player (per-player override)
- Everyone (global)
Two flags exist:
- Change globally: applies the configured options to the NPC’s global options
- Reset to default: removes per-player overrides and resets to the NPC’s defaults
Stops the current chain immediately (and stops nested chains too).
In the action editor you can enable Run on show.
If enabled, the chain triggers when the NPC is shown to a player (not only when clicked).