Action Registry

Actions are config-driven commands executed on a player. Each action is a string in the format [key] text.

Built-in actions

Key
Description

[message]

Send a message to the player

[broadcast_message]

Broadcast a message to all players

[console]

Run a command from console

[player]

Run a command as the player

[effect]

Apply a potion effect

[action_bar]

Send an action bar message

[broadcast_action_bar]

Broadcast an action bar to all players

[title]

Send a title to the player

[broadcast_title]

Broadcast a title to all players

[sound]

Play a sound for the player

[broadcast_sound]

Play a sound for all players

[open]

Open a GUI

Usage

Simple run:

ActionExecute.run(ActionContext.of(player), "[message] Hello!");

With extra objects in context:

ActionExecute.run(
    ActionContext.of(player).with(entity),
    "[myplugin:give_diamond] 64"
);

Extra objects added via .with() can be retrieved inside the handler using ctx.get(YourClass.class).


Registering a custom action

Custom actions are registered in onEnable and unregistered in onDisable.

Actions from different plugins can share the same key without conflict — the full key is namespace:command:

Lambda (simple cases)

Class (recommended for complex logic)

Register in onEnable:

Implement Action:

ActionContext

ActionContext is a type-safe container for objects passed into an action. Objects are stored and retrieved by class — no string keys needed.

If you want to store an object under an interface rather than its concrete class:

Last updated