Plugin API
Commands and Scheduler
Register commands and run tasks later.
Updated Dec 5, 2026
Commands
SimpleCommand gives you Spigot-style args[] commands with aliases, a permission and tab completion:
use rocketmc_plugin_api::prelude::*;
SimpleCommand::new(["hello"], "Greets a player")
.executor(|sender, _server, args| {
let who = args.get(0).unwrap_or("there");
sender.send_message(&TextComponent::text(format!("Hello, {who}!")));
Ok(())
})
.register(&context)?;
CommandArgs has get, parse_at::<T> and join_from. For typed arguments, build a Command with CommandNode instead.
Command helpers
| Module | What it does |
|---|---|
selector | selector::resolve(&server, Some(&sender), "@a" | "@s" | "@r" | "@p" | name) turns a target into players, and complete feeds tab completion |
help::HelpBook | HelpBook::new(title).entry(usage, desc).render(page, per_page) for a /help page |
pagination::Paginator | Page any list for a command |
confirm::Confirmations | /confirm flows: request(key, payload, ttl) then confirm(&key) |
ratelimit::RateLimiter | Sliding window anti-spam: allow(key, max, window) |
cooldown::Cooldowns | Thread-safe try_use, remaining and reset |
prompt | Ask a player a question in chat and get the answer in a callback |
Scheduler
Time is measured in ticks; 20 ticks is about one second. Tasks run on the main tick loop.
use rocketmc_plugin_api::{logging::{log, LogLevel}, scheduler::{cancel_task, SchedulerExt}};
context.schedule_delayed_task(20, |_server| {
log(LogLevel::Info, "one second has passed");
});
let id = context.schedule_repeating_task(100, 100, |_server| {
log(LogLevel::Info, "every five seconds");
});
cancel_task(id);
Callbacks can run again later, so shared mutable state needs Arc<Mutex<..>> or atomics.
Bukkit-style task helpers
The tasks module wraps the scheduler: run_task, run_later, run_timer, run_timer_limited(delay, period, times, f) and run_countdown(seconds, on_tick, on_finish). Each returns a TaskHandle you can cancel().
The time module converts for you: seconds_to_ticks, minutes_to_ticks, parse_ticks("1h30m") and format_duration. Units are d h m s t.
The animation module has pure functions of the current tick (cycle, scroll, typewriter, rainbow, flash) for animated titles and scoreboards.
Never block inside an event handler or a task. Keep them short.
worldedithelpers run inside the call, so split big jobs across ticks withtasks::run_timer_limited.