Commands / Actions & triggers
Actions & triggers
An action is something an NPC does when a player interacts with it. A trigger is what kind of click causes it. You attach actions with /npc action <name> <trigger> add <type> <value>.
Triggers
| Trigger | Fires on |
|---|---|
interact | Right-clicking the NPC |
left_click | Left-clicking (attacking) the NPC |
any | Either kind of click |
Action types
| Type | Value format | What it does |
|---|---|---|
message | any text | Sends the text to the player who clicked, privately |
broadcast | any text | Sends the text to every player on the server |
command | a command, without the slash | Runs the command as the clicking player |
console_command | a command, without the slash | Runs the command as the server console — use this for commands the player shouldn't normally have permission for |
teleport | world,x,y,z | Teleports the clicking player there |
sound | SOUND_NAME,volume,pitch | Plays a sound for the clicking player. Volume and pitch are optional and default to 1.0 |
give_item | a material name | Gives the clicking player one of that item |
Placeholders inside actions
Two placeholders work inside any action's text or command:
| Placeholder | Replaced with |
|---|---|
{player} | The name of the player who clicked |
{npc} | The name of the NPC that was clicked |
Examples
/npc action Bob interact add message Welcome, {player}!
/npc action Bob interact add sound ENTITY_VILLAGER_YES,1.0,1.2
/npc action Shopkeeper interact add command shop open {player}
/npc action Guard left_click add console_command kick {player} No hitting the guards!
Cooldowns only apply when there's something to cool down
If an NPC has no actions configured for the trigger you used, nothing happens and no cooldown message is shown — the plugin only checks the cooldown when there's actually an action waiting to fire.