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 actions.success, actions, deny_actions, or result.success.actions, 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
actions:
  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.
bossbarshowrequired id, title; progress=1; color=purple; style=solid; flags=""YesShows or updates a boss bar. Reusing an id updates the existing bar.
bossbarhiderequired idYesHides a boss bar. Pass all to hide every bar.
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 accepts auto, vault, or excellenteconomy. With auto, CoreLib prefers ExcellentEconomy when a currency is given and otherwise falls back to Vault. currency must be set explicitly when using ExcellentEconomy with multiple 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, Nexo, or Oraxen block source.
giveitemsource=""; amount=1YesGives an item source directly into the player inventory.
setitemslot=mainhand; source=""; amount=1YesSets the item in a player inventory slot.
takeitemsource=""; amount=1YesRemoves matching items from the player inventory.
repairitemslot=mainhand; amount=0YesRepairs durability. amount <= 0 repairs fully.
damageitemslot=mainhand; amount=1; delete_item=falseYesAdds durability damage, optionally removing the item when it breaks.
setblockmaterial=""; block=""; block_data=""; apply_physics=true; world=""; x/y/zOnly for relative coordinates or omitted worldSets a block. block is an alias of material.
breakblockdrop_items=false; apply_physics=true; world=""; x/y/zOnly for relative coordinates or omitted worldBreaks the block at the given location.
spawnentityrequired type; count=1; world=""; x/y/zOnly for relative coordinates or omitted worldSpawns entities at a location.
killentitytype=""; radius=1; limit=1; include_players=false; world=""; x/y/zOnly for relative coordinates or omitted worldRemoves entities within a radius.
explosionpower=0; fire=false; break_blocks=false; world=""; x/y/zOnly for relative coordinates or omitted worldCreates an explosion.

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.
feedamount=20; saturation=0YesRestores food points and saturation.
igniteduration=5sYesSets the player on fire.
extinguishnoneYesExtinguishes the player.
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.

Loop actions

These three actions are only registered when the loop feature is available (action.loop.enabled in config.yml). They repeatedly execute an action template, subject to the quotas under action.loop.*.

Action IDParametersRequires playerDescription
loopsyncrequired template, times, interval; initial_delay=0t; key=""; mode=replace; stop_if_offline=true; stop_if_dead=false; stop_if_condition=""; stop_on_failure=falseDepends on templateStarts a synchronous repeating action template.
loopasyncSame as loopsyncDepends on templateStarts an async-safe repeating action template.
cancellooprequired key; match=exact; silent=trueNoCancels running loop tasks by key.

mode accepts replace, refresh, ignore, and allow_duplicate. match accepts exact or prefix.

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.

The script action ID is fixed to runjs. 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.

Listing and running registered actions from commands

Administrators can inspect the current action registry and run one registered action by ID from the server:

text
/corelib action list
/corelib action run <actionId> key=value ...

The same subcommand is available through /emakicorelib action, /emakicore action, and the plural alias actions. It reuses the emakicorelib.admin permission. Console execution has no player context, so actions that require a player fail through the normal Action validation path. There is intentionally no “run all actions” command to avoid accidental mass execution.

action list shows id, category, source, owner, execution mode, and parameter names. action run passes <actionId> key=value ... to the existing ActionExecutor as one action line, so parameters, quoting, @if, @chance, and @delay follow the same rules as YAML action lines.

Where to find sub-plugin CoreLib actions

CoreLib provides the shared registry and executor. Business plugins may append their own actions when enabled. To avoid turning this CoreLib page into a stale table of every plugin-specific action, this page only documents CoreLib built-in actions.

CoreLib actions registered by sub-plugins are now documented on their own plugin pages:

Source moduleDocumentation
EmakiAttributeAttribute CoreLib Actions
EmakiForgeForge CoreLib Actions
EmakiStrengthenStrengthen CoreLib Actions
EmakiCookingCooking CoreLib Actions
EmakiGemGem CoreLib Actions
EmakiLevelLevel CoreLib Actions
EmakiSkillsSkills CoreLib Actions
EmakiItemItem CoreLib Actions
EmakiCodexCodex CoreLib Actions
JavaScript extensionsJavaScript

If an action is provided by a business plugin, its parameters, context variables, and execution timing are defined by that plugin’s documentation.

Registering actions from third-party plugins

Third-party developers can depend only on emaki-corelib-api and call EmakiCoreLibApi.registerAction(plugin, source, action) to add custom actions to CoreLib's shared action registry. Use a stable lowercase source id such as myplugin. On plugin disable, call the returned CoreActionRegistration.unregister() handle or use EmakiCoreLibApi.unregisterActions(plugin) to remove all actions owned by that plugin.

A custom action implements CoreAction and declares its id, category, description, parameters, and executionMode. CoreLib reuses the same action-line parser, parameter checks, @if / @chance / @delay control prefixes, debug output, and dispatch scheduler. Read-only discovery is available through EmakiCoreLibApi.actions(), action(id), actionsBySource(source), and actionsByOwner(plugin).

Minimal example:

java
CoreActionRegistration registration = EmakiCoreLibApi.registerAction(plugin, "myplugin", new CoreAction() {
    @Override
    public String id() {
        return "mycustomaction";
    }

    @Override
    public String category() {
        return "myplugin";
    }

    @Override
    public String description() {
        return "Runs my plugin's custom effect.";
    }

    @Override
    public List<CoreActionParameter> parameters() {
        return List.of(CoreActionParameter.required("value", CoreActionParameterType.STRING, "Custom value"));
    }

    @Override
    public CoreActionResult execute(CoreActionContext context, Map<String, String> arguments) {
        // Run your plugin logic here. Keep the default SYNC mode when using Bukkit main-thread APIs.
        return CoreActionResult.ok();
    }
});

// On plugin disable:
registration.unregister();
// Or: EmakiCoreLibApi.unregisterActions(plugin);

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.