Skip to content

Automation API

github-actions[bot] edited this page Oct 26, 2026 · 1 revision

Automation API (API 2.1.0)

Four building blocks for mods, available from ControlCoreApi.get() (or find()).

Notifications

api.notifications().message(player, "Hello");
api.notifications().message(player, "Careful!", "#ff5555");
api.notifications().broadcast("Restart in 5 minutes");
api.notifications().toAdmins("Backup finished");
api.notifications().title(player, "Welcome!", "Have fun");
api.notifications().titleAll("Event", "starts now");

Scheduler

SchedulerApi.Task task = api.scheduler().every(Duration.ofMinutes(30), () -> ...);
api.scheduler().later(Duration.ofSeconds(10), () -> ...);
api.scheduler().dailyAt(LocalTime.of(20, 0), () -> ...);
task.cancel();

Work runs on a background thread; hop to a world's thread before touching that world. A failing run is logged and later runs continue.

Sessions

api.sessions().find(player).ifPresent(session -> {
    Duration total = session.playtime();      // including the current session
    Instant first = session.firstJoin();
    boolean online = session.online();
});
api.sessions().world(player);                 // the world the player is in

Actions and triggers for rules

Offer an action admins can pick in the Automation tab ("Mod action" with the value homes:reset-homes):

api.actions().register(AutomationAction.of("homes", "reset-homes")
        .displayName("Reset everyone's homes")
        .run(context -> homes.resetAll()));

ActionContext holds the rule's name, the player (if the trigger had one), the text the admin typed after the id (with placeholders filled in) and the trigger's placeholders.

Announce your own trigger ("A mod's trigger" with the value arena:match-won) and fire it:

api.actions().registerTrigger("arena", "match-won", "An arena match is won");
api.actions().fire("arena", "match-won", Optional.of(winner), Map.of("arena", "Lava pit"));

Rules can then use {arena}. /cc-rules lists every registered action and trigger.

Clone this wiki locally