⚡ Action Registry
ActionRegistry lets addons register custom EventForge action types.
Custom actions can then be used inside normal EventForge event configs.
Accessing the registry
ActionRegistry actionRegistry = EventForgeAPI.getActionRegistry();
Always check the API first:
if (!EventForgeAPI.isAvailable()) {
return;
}
Basic custom action
EventForgeAPI.getActionRegistry().register("DISCORD_LOG", (action, context) -> {
String message = action.getString("message", "{event_display} triggered an action.");
String parsed = context.parsePlaceholders(message);
Bukkit.getLogger().info("[DISCORD_LOG] " + parsed);
});
Server owners can then use:
triggers:
event-start:
actions:
- type: DISCORD_LOG
message: "{event_display} started!"
Action IDs
Action IDs should be uppercase and unique.
Good examples:
DISCORD_LOG
RELIC_LOG
SPAWN_SUPPLY_DROP
CUSTOM_REWARD
Avoid using built-in EventForge action names.
Built-in actions include:
BROADCAST
MESSAGE
TITLE
ACTIONBAR
ANIMATED_TITLE
ANIMATED_ACTIONBAR
SOUND
COMMAND
EFFECT
PARTICLE
FIREWORK
WEBHOOK
Protected built-in actions
EventForge protects built-in action types.
This means addons cannot accidentally unregister core EventForge actions.
Protected actions include:
BROADCAST
MESSAGE
TITLE
ACTIONBAR
SOUND
COMMAND
EFFECT
PARTICLE
FIREWORK
WEBHOOK
ANIMATED_TITLE
ANIMATED_ACTIONBAR
Reading action values
Use the action object to read values from config.
EventForgeAPI.getActionRegistry().register("RELIC_LOG", (action, context) -> {
String message = action.getString("message", "Relic action triggered.");
String parsed = context.parsePlaceholders(message);
Bukkit.getLogger().info(parsed);
});
Example config:
actions:
- type: RELIC_LOG
message: "{player} found a relic in {event_display}."
Player context
Some actions may need a player.
EventForgeAPI.getActionRegistry().register("CUSTOM_MESSAGE", (action, context) -> {
context.getPlayer().ifPresent(player -> {
String message = action.getString("message", "Hello!");
player.sendMessage(context.parsePlaceholders(message));
});
});
If the action runs from a trigger without a player, context.getPlayer() may be empty.
Using placeholders
Custom actions can parse EventForge placeholders through the action context.
String parsed = context.parsePlaceholders("{player} scored in {event_display}.");
This supports normal placeholders and extra placeholders provided by the system running the action.
Using text effects
You can use the public text effect service inside custom actions.
EventForgeAPI.getActionRegistry().register("STYLED_LOG", (action, context) -> {
String message = action.getString("message", "<gradient:#22d3ed:#ffffff>{event_display}</gradient>");
String parsed = context.parsePlaceholders(message);
String styled = EventForgeAPI.getTextEffectService().parse(parsed);
Bukkit.getLogger().info(styled);
});
Register on enable
Register your custom action when your addon enables.
@Override
public void onEnable() {
if (!EventForgeAPI.isAvailable()) {
getServer().getPluginManager().disablePlugin(this);
return;
}
EventForgeAPI.getActionRegistry().register("RELIC_LOG", new RelicLogAction(this));
}
Unregister on disable
Unregister your custom action when your addon disables.
@Override
public void onDisable() {
if (EventForgeAPI.isAvailable()) {
EventForgeAPI.getActionRegistry().unregister("RELIC_LOG");
}
}
This helps keep reloads clean.
Example action class
public final class RelicLogAction implements EventActionExecutor {
private final JavaPlugin plugin;
public RelicLogAction(JavaPlugin plugin) {
this.plugin = plugin;
}
@Override
public void execute(EventAction action, EventActionContext context) {
String message = action.getString("message", "Relic action triggered.");
String parsed = context.parsePlaceholders(message);
String styled = EventForgeAPI.getTextEffectService().parse(parsed);
plugin.getLogger().info("[RelicLog] " + styled);
}
}
Using custom actions in milestones
Custom actions work anywhere EventForge actions are supported.
Example:
milestones:
enabled: true
thresholds:
25:
display-name: "&e25 Points"
once-per-player: true
actions:
- type: RELIC_LOG
message: "{player} reached {milestone_display} in {event_display}."
Using custom actions in objectives
Custom actions can also be used inside objective-specific action sections if the objective supports actions.
Example:
objective:
type: VISIT_REGIONS
regions:
market:
display-name: "&eMarket"
world: world
x1: 30
y1: 64
z1: 30
x2: 45
y2: 72
z2: 45
points: 5
once-per-player: true
actions:
- type: RELIC_LOG
message: "{player} visited {region_display}."
Summary
Use ActionRegistry when your addon needs to add new action types.
Custom actions can be used in:
triggers
milestones
supported objective action sections
custom addon systems
For executing normal EventForge actions from your addon, use ActionService.