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

TriggerFires on
interactRight-clicking the NPC
left_clickLeft-clicking (attacking) the NPC
anyEither kind of click

Action types

TypeValue formatWhat it does
messageany textSends the text to the player who clicked, privately
broadcastany textSends the text to every player on the server
commanda command, without the slashRuns the command as the clicking player
console_commanda command, without the slashRuns the command as the server console — use this for commands the player shouldn't normally have permission for
teleportworld,x,y,zTeleports the clicking player there
soundSOUND_NAME,volume,pitchPlays a sound for the clicking player. Volume and pitch are optional and default to 1.0
give_itema material nameGives the clicking player one of that item

Placeholders inside actions

Two placeholders work inside any action's text or command:

PlaceholderReplaced 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.