Pumpkin-MC/Pumpkin · error
expected ServerListPingEvent
Error message
expected ServerListPingEvent
What it means
This panic comes from the `EventLike` trait's `data_from_event` glue for ServerListPingEvent. The event dispatcher hands an `Event` enum to the handler bridge, which destructures it into its typed payload; if the variant is not `Event::ServerListPingEvent`, the bridge panics with "expected ServerListPingEvent". This means the internal event-routing invariants were violated — the dispatcher delivered an event to a handler registered for a different event type.
Solutions
- Verify the handler is registered under EventType::ServerListPingEvent so the dispatcher routes matching variants to it.
- Update the plugin API and dispatcher to the same version so Event enum variants and EventType keys stay in sync.
- Check any custom event forwarding code for a swap between ServerListPingEvent and another Event variant.
- Replace the panic with a logged error / no-op if the bridge should tolerate misrouted events.
Example fix
// before
Event::ServerListPingEvent(data) => data,
_ => panic!("expected ServerListPingEvent"),
// after
Event::ServerListPingEvent(data) => data,
other => {
log::warn!("misrouted event {:?}, expected ServerListPingEvent", other.event_type());
return Default::default();
} Defensive patterns
Strategy: validation
Validate before calling
// assert route correctness before invoking the bridge assert_eq!(<ServerListPingHandler as EventLike>::EVENT_TYPE, event.event_type(), "misrouted event");
Type guard
fn as_server_list_ping<'a>(event: &'a Event) -> Option<&'a ServerListPingEventData> {
if let Event::ServerListPingEvent(data) = event { Some(data) } else { None }
} Try / catch
// Rust panics are not catchable across FFI; use catch_unwind at the dispatch boundary
let result = std::panic::catch_unwind(AssertUnwindSafe(|| bridge.data_from_event(event)));
if result.is_err() { log::error!("misrouted event for ServerListPingEvent handler"); } Prevention
- Always register handlers with the exact EventType constant defined by their EventLike impl
- Keep the plugin crate and server on the same pumpkin-plugin-api version
- In custom dispatchers, filter events by event_type() before invoking a handler
- Prefer matching with `if let Event::Variant(..)` over panicking bridges in your own glue
When it happens
Trigger: Calling `data_from_event` (directly or via the plugin-event bridge) with an `Event` variant other than `Event::ServerListPingEvent` — e.g. an event bus that registered a ServerListPing listener under the wrong EventType key, or hand-rolled dispatch code that passes raw events to the wrong trait implementation.
Common situations: Plugin API version changes that renamed/reordered Event variants so old dispatch tables map to the wrong handler; a custom scheduler or event forwarder that mixes up EventType registration keys; writing a custom EventLike impl and copying the wrong Data type into it.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/160c4e9ad19e726c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-plugin-api/src/events/server/server_list_ping.rs:18
use crate::wit::pumpkin::plugin::event::{Event, EventType, ServerListPingEventData};
use super::super::FromIntoEvent;
/// Fires when the server prepares a Java status/list ping response.
///
/// Register this as a blocking event handler to customize the MOTD, favicon,
/// and reported player counts for WASM plugins.
pub struct ServerListPingEvent;
impl FromIntoEvent for ServerListPingEvent {
const EVENT_TYPE: EventType = EventType::ServerListPingEvent;
type Data = ServerListPingEventData;
fn data_from_event(event: Event) -> Self::Data {
match event {
Event::ServerListPingEvent(data) => data,
_ => panic!("expected ServerListPingEvent"),
}
}
fn data_into_event(data: Self::Data) -> Event {
Event::ServerListPingEvent(data)
}
}
View on GitHub (pinned to 8d4639e25a)