Skip to content

Action System

The action system lets YAML configuration describe what should happen after a business event. It is one of the most frequently used CoreLib features across Forge, Strengthen, Gem, Cooking, Skills, Item, and Attribute.

Basic syntax

Different modules may use different field names, such as action.success, actions, deny_actions, or result.action, but the idea is the same: an action list is executed in order.

An action line consists of control prefixes, an action ID, and key=value arguments:

text
@chance=25% @delay=20t sendmessage text="<green>Triggered</green>"

Use quoted values whenever a value contains spaces, commands, MiniMessage tags, or YAML-sensitive characters.

yaml
action:
  success:
    - 'sendmessage text="<green>Forge success!</green>"'
    - 'playsound sound=minecraft:entity.player.levelup volume=1 pitch=1'
    - 'runcommandasconsole command="say %player_name% completed a forge"'

CoreLib resolves placeholders before executing the action. Built-in context placeholders include %player_name%, %player_uuid%, %player_world%, %player_x%, %player_y%, %player_z%, and %phase%. Business modules may inject additional placeholders.

Parser notes

  • Blank lines and lines starting with # are ignored.
  • Action IDs are normalized to lower case. Built-in IDs generally do not contain underscores.
  • Arguments must be written as key=value; a token without = after the action ID is a syntax error.
  • Duplicate arguments in one line are rejected.
  • Single and double quotes are both supported. Quoted values support \n, \t, \\, \", and \' escaping.
  • createitem, clearitem, dropitem, placeblock, runjs, and usetemplate accept dynamic arguments.

Control prefixes

Control prefixes must appear before the action ID:

PrefixMeaning
@if=<expression>Run only when the expression is true.
@chance=<number>Run by chance. Supports decimals from 0 to 1 and percent values such as 25%.
@delay=<time>Run after a delay. Supports ticks, t, s, and ms, such as 20, 20t, 1s, 500ms.
@ignore_failureContinue the following actions even if this action fails.
yaml
actions:
  - '@chance=0.1 broadcastmessage text="<gold>%player_name% triggered a rare reward!</gold>"'
  - '@delay=1s sendmessage text="<gray>This message is delayed by one second"'
  - '@if=%player_world%=="world" sendmessage text="You are in the overworld"'
  - '@ignore_failure runcommandasconsole command="papi parse %player_name% %some_placeholder%"'

@if supports boolean literals, numeric truthiness, comparisons, &&, ||, !, and parentheses. String comparisons should be quoted.

Built-in action IDs and parameters

Messages and feedback

Action IDParametersRequires playerDescription
sendmessagerequired textYesSends a MiniMessage chat message to the player.
sendtitlerequired title; subtitle=""; fade_in=10t; stay=40t; fade_out=10tYesSends a title. Time values support t/s/ms.
sendactionbarrequired textYesSends an action bar message.
broadcastmessagerequired textNoBroadcasts a MiniMessage message to the server.
playsoundrequired sound; volume=1; pitch=1YesPlays a Bukkit sound at the player location.
spawnparticlerequired particle; count=1; target=player; world; x/y/z; offset_x/y/z=0; extra=0Only when target=playerSpawns particles at the player or at a configured location.
yaml
actions:
  - 'sendmessage text="<green>Reward: <yellow>100 coins</yellow></green>"'
  - 'sendtitle title="<gold>Success</gold>" subtitle="<gray>Level up</gray>" fade_in=5t stay=40t fade_out=10t'
  - 'playsound sound=minecraft:entity.experience_orb.pickup volume=0.8 pitch=1.2'
  - 'spawnparticle particle=happy_villager count=10 offset_x=0.3 offset_y=0.6 offset_z=0.3'

Economy

Action IDParametersRequires playerDescription
givemoneyrequired amount; provider=auto; currency=""YesAdds money to the player.
takemoneyrequired amount; provider=auto; currency=""YesTakes money from the player.
setmoneyrequired amount; provider=auto; currency=""YesSets the player balance.

provider is usually auto, vault, or excellent. currency only matters when the selected economy provider supports currencies.

Temporary items

createitem creates a temporary item in the current action context. senditem can then give it to the player.

Action IDParametersRequires playerDescription
createitemrequired id; source=""; amount=1; dynamic aliases item, item_sourceNoCreates a temporary item from an item source.
senditemrequired id; keep=falseYesSends a temporary item to the player. Leftovers are dropped nearby.
clearitemrequired slot; source=""; dynamic aliases item, item_sourceYesClears a player inventory slot, optionally only when the item source matches.
dropitemrequired x/y/z; world=current; source=""; amount=1; dynamic aliases item, item_sourceOnly for relative coordinates or omitted worldDrops an item source at an exact location.
placeblockrequired x/y/z; world=current; source=""; dynamic aliases item, item_sourceOnly for relative coordinates or omitted worldPlaces a vanilla, CraftEngine, ItemsAdder, or Nexo block source.

source uses the CoreLib item source shorthand. See Item Sources.

clearitem.slot supports mainhand, offhand, helmet, chestplate, leggings, boots, and inventory indexes 0 to 35 (slot_0, hotbar_0 are also accepted).

dropitem and placeblock coordinates support ~ relative notation when a player context exists. Without a player context, configure world and absolute coordinates.

yaml
actions:
  - 'createitem id=reward source=minecraft:diamond amount=3'
  - 'senditem id=reward'
  - 'clearitem slot=mainhand source=minecraft:stick'
  - 'placeblock source=minecraft-stone world=world x=100 y=64 z=-20'
  - 'placeblock source=ce-cutting_board x=~1 y=~ z=~'
  - 'dropitem source=nexo-reward_coin amount=3 x=~ y=~1 z=~'

Player state and teleport

Action IDParametersRequires playerDescription
teleportrequired x, y, z; world=current; yaw=0; pitch=0YesTeleports the player. Coordinates support ~ relative notation.
healrequired amountYesHeals the player, capped by max health.
damagerequired amountYesReduces player health, not below 0.
sethealthrequired amountYesSets player health, clamped to 0..max health.
yaml
actions:
  - 'heal amount=4'
  - 'damage amount=2'
  - 'teleport world=world x=~ y=~1 z=~ yaw=0 pitch=0'

Experience and potion effects

Action IDParametersRequires playerDescription
giveexprequired amount; mode=pointsYesAdds experience points or levels. Use mode=levels for levels.
takeexprequired amount; mode=pointsYesRemoves experience points or levels, not below 0.
setexprequired amount; mode=pointsYesSets total experience points or levels.
givepotioneffectrequired type, level, duration; ambient=false; particles=true; icon=trueYesAdds a potion effect. level=1 maps to Bukkit amplifier 0.
removepotioneffectrequired typeYesRemoves one potion effect.
clearpotioneffectsnoneYesClears all active potion effects.

type can be written as speed or minecraft:speed. duration supports t/s/ms.

Commands

Action IDParametersRequires playerDescription
runcommandasplayerrequired commandYesDispatches a command as the player.
runcommandasoprequired commandYesTemporarily grants OP, runs the command, then restores the original OP state.
runcommandasconsolerequired commandNoDispatches a command as the console.

A leading / is stripped automatically, but omitting it in config is recommended.

yaml
actions:
  - 'runcommandasplayer command="spawn"'
  - 'runcommandasop command="lp user %player_name% permission set example.use true"'
  - 'runcommandasconsole command="say %player_name% completed a task"'

Action templates

Define templates in the CoreLib main config:

yaml
action:
  templates:
    reward_common:
      - 'sendmessage text="<green>Reward claimed</green>"'
      - 'playsound sound=minecraft:entity.experience_orb.pickup volume=0.8 pitch=1.2'

Call them with usetemplate:

yaml
actions:
  - 'usetemplate name=reward_common'
ParameterDescription
nameRequired template ID. Case-insensitive.
with.<key>Dynamic value injected as %template_<key>% inside the template.

Template nesting is limited to 8 levels.

MythicMobs and JavaScript

Action IDParametersRequires playerDescription
castmythicskillrequired skillYesUses the MythicMobs API to make the player cast a skill. Fails gracefully if MythicMobs is unavailable.
runjsrequired script; function=main; timeout=default; silent=false; dynamic arg_*NoRuns a JavaScript file from the CoreLib script repository.

runjs aliases come from config.yml; defaults are runscript and javascript. arg_foo=bar becomes script argument foo=bar.

yaml
actions:
  - 'castmythicskill skill=FireballSkill'
  - 'runjs script=examples/hello.js function=main timeout=1000 arg_source=forge arg_amount=3'

See JavaScript for the script API.

Actions registered by other modules

ModuleAction IDsDescription
EmakiSkillscastskillCasts an EmakiSkills skill.
EmakiAttributeattributedamage, attribute_add, attribute_set, attribute_removeAttribute damage and attribute mutation actions.
CoreLib script configaliases of runjsDefaults: runscript, javascript.

Troubleshooting

Action does not execute

Check whether:

  1. The field is actually an action field for the module.
  2. YAML indentation is correct.
  3. The action ID is spelled correctly and does not contain underscores.
  4. @if or @chance skipped the action.
  5. The console contains action syntax errors.

Argument parsing fails

Common causes:

  • Old space-style syntax such as sendmessage <green>Success; use sendmessage text="<green>Success" instead.
  • command or text contains spaces but is not quoted.
  • Duplicate argument keys.
  • Unclosed quotes.

Economy actions do nothing

Check whether Vault / ExcellentEconomy is installed and detected, whether provider / currency is correct, and whether the player has enough balance for take operations.