Concepts
Events
Events are the older, simpler half of the API. The server tells a plugin that something
happened, and the plugin answers Outcome::Continue or Outcome::Cancel.
fn on(&self, host: &dyn Host, event: &Event) -> Outcome
- One closed enum.
rustmc_plugin::Eventlists everything a plugin can be told. See the event reference. - Cancelling is a return value. The first cancel stands, and every other subscriber still runs. That way a plugin keeping a count still gets its count, and load order never decides a rule.
- A
Firstplugin's cancel ends the event. When a plugin atFirstcancels a cancellable event, later plugins are not told, exceptObservers. Nothing acts on, logs or counts what will not happen. A cancel at any other priority stops nobody. - Not every event can be cancelled.
Event::is_cancellablesays which. Cancelling a death does nothing, because the death has already happened. - Subscribing.
Manifest::hearing(&["block_break", ...]). An empty list means every event.
Every event is also a hook point with the same name, so you can also prepend to,
override or append to block_break. Use an event when you only need to watch or veto. Use a
hook when you need to change what happens.
Priorities
| Priority | For |
|---|---|
First | a plugin that decides first: its cancel ends the event for all but observers |
Early | |
Normal | the default |
Late | |
Observer | watching the final answer. By convention it must not cancel |
From docs/api/concepts/events.md in the RustMC repository at bbd81209ad.