Interactions
What an NPC does when clicked is a list of steps, one per line, run in order. Left and right clicks have their own lists.
Editing the list
/abb interaction <id> <left|right|both> <option> [...]| Option | Example | Does |
|---|---|---|
add <step> | add [message] <green>Hi! | Adds a step at the end |
add_before <n> <step> | add_before 1 [wait] 20 | Adds a step before step n |
add_after <n> <step> | add_after 2 [playsound] entity.villager.yes 1 1 | Adds a step after step n |
set <n> <step> | set 3 [console] give {player} diamond 1 | Replaces step n |
remove <n> | remove 2 | Removes step n |
move_up <n>, move_down <n> | move_up 3 | Moves step n |
list | list | Shows the steps, numbered |
clear | clear | Removes them all |
both changes the left and the right list at once.
Steps
| Step | Does |
|---|---|
[message] <text> | A chat message to the player (MiniMessage) |
[broadcast] <text> | A message to everybody |
[playsound] <sound> [volume] [pitch] | Plays a sound to the player |
[player] <command> | Runs a command as the player |
[console] <command> | Runs a command as the server |
[server] <name> | Sends the player to another server (needs a proxy: Velocity, BungeeCord) |
[wait] <ticks> | Waits before the next step (20 ticks = 1 second) |
[need_permission] <permission> | Stops here if the player lacks it |
[need_item] <ITEM>:<amount> | Stops here unless the player carries it |
[block_until_done] | Ignores more clicks until the list finishes |
A line with no tag runs as the player.
Tokens
| Token | Becomes |
|---|---|
{player} {player_uuid} {player_display} | The player's name, UUID and display name |
{npc_id} {npc_name} {npc_model} | The NPC's id, name and model |
{npc_world} {npc_x} {npc_y} {npc_z} | Where the NPC is |
With PlaceholderAPI, %placeholders% work too, filled in after the tokens.
An example: a shop keeper
yaml
right-click-commands:
- "[need_permission] shop.use"
- "[block_until_done]"
- "[message] <green>Welcome, {player}!"
- "[playsound] entity.villager.yes 1 1.2"
- "[wait] 40"
- "[player] warp shop"That is how it is stored in npcs.yml. The same with commands:
/abb interaction keeper right add [need_permission] shop.use
/abb interaction keeper right add [block_until_done]
/abb interaction keeper right add [message] <green>Welcome, {player}!
/abb interaction keeper right add [playsound] entity.villager.yes 1 1.2
/abb interaction keeper right add [wait] 40
/abb interaction keeper right add [player] warp shopBy default a click cannot be repeated within a second (settings.default-interaction-cooldown in config.yml, in milliseconds).