Plugin API
Events
Listen to, modify and cancel things that happen in the world.
Updated Dec 5, 2026
Events are typed markers connected to WIT event data. A handler receives the event data and, if it is a blocking handler, returns it possibly changed.
Closures
The shortest way to listen. listen observes and never changes the event. on can change or cancel it and always runs as a blocking handler.
use rocketmc_plugin_api::events::{EventPriority, PlayerJoinEvent, PlayerJumpEvent};
use rocketmc_plugin_api::prelude::*;
fn on_load(&self, ctx: Context) -> Result<()> {
// observe
ctx.listen::<PlayerJumpEvent, _>(|_server, e| e.player.send_message("&7boing"))?;
// modify or cancel
ctx.on::<PlayerJoinEvent, _>(EventPriority::Normal, |_server, mut event| {
event.join_message = TextComponent::text("");
event
})?;
Ok(())
}
Handler types
When a handler needs its own state, implement EventHandler on a type:
struct NoJoinMessage;
impl EventHandler<PlayerJoinEvent> for NoJoinMessage {
fn handle(&self, _server: Server, mut event: PlayerJoinEventData) -> PlayerJoinEventData {
event.join_message = TextComponent::text("");
event
}
}
// in on_load:
ctx.register_event_handler(NoJoinMessage, EventPriority::Normal, false)?;
Listener classes
For a group of related handlers, implement Listener, in the style of Bukkit's registerEvents:
struct Greeter;
impl Greeter {
fn on_join(&self, _server: Server, e: &PlayerJoinEventData) {
e.player.send_message("&aWelcome!");
}
}
impl Listener for Greeter {
fn register(self: Arc<Self>, ctx: &Context) -> Result<()> {
ctx.listen_with::<PlayerJoinEvent, _>(&self, Self::on_join)?;
Ok(())
}
}
// in on_load:
ctx.register_listener(Arc::new(Greeter))?;
ctx.on_with is the modifying counterpart of ctx.listen_with.
Priorities and blocking
Priorities are Highest, High, Normal, Low and Lowest. Handlers run in priority order. The last argument of register_event_handler is blocking: a blocking handler gets exclusive access to the event data and can change it, for example by setting cancelled = true.
Most event data carries a cancelled flag. A blocking handler that sets it stops the vanilla behaviour.
Event groups
| Group | Examples |
|---|---|
player | Join, leave, login, kick, chat, move, jump, teleport, interact, inventory clicks, commands, game mode, respawn, portals, fishing, riptide, experience pickup |
block | Break, place, burn, ignite, explode, pistons, physics, redstone, dispense, leaves decay, sculk bloom, sign change |
entity | Damage, death, spawn, target, breed, tame, portals, potion effects, projectiles, villager trades, warden anger |
inventory, hanging, raid, vehicle | Events for those systems |
server, world | Server and world level events |
dialog, enchantment | Dialog and enchanting events |
packet | Raw Java and Bedrock packet interception |
Look in modules/rocketmc-plugin-api/src/events/ for the full list.
Newer events
| Event | Fired when | Cancelling it |
|---|---|---|
PlayerJumpEvent | A player jumps, at the vanilla jump detection point | Skips the server side jump effects (exhaustion and the jump statistic). The movement itself is not undone, because player movement is client authoritative |
PlayerPickupExperienceEvent | A player touches an experience orb, after the pickup delay check | Leaves the orb in the world. You can also change amount, which then goes through mending |
Handlers run inside the server tick. Keep them short and never block.