IEventBus
IEventBus
Section titled “IEventBus”Package: com.hypixel.hytale.event
public interface IEventBus extends IEventRegistryThe core event dispatch interface. Extends IEventRegistry (which defines listener registration methods) with methods for dispatching events to registered listeners. The server’s EventBus implementation is the concrete class backing this interface.
Plugins do not typically interact with IEventBus directly. Registration goes through the plugin-scoped EventRegistry, and dispatch is performed by the server internally. This interface is documented for understanding the event system architecture.
Relationship to IEventRegistry
Section titled “Relationship to IEventRegistry”IEventRegistry defines the registration side of the event system — all the register(), registerAsync(), registerGlobal(), registerUnhandled(), and their variants. IEventBus adds the dispatch side: methods that fire events to registered listeners.
IEventRegistry (registration) └── IEventBus (registration + dispatch) └── EventBus (concrete implementation)EventRegistry also implements IEventRegistry as a plugin-scoped proxy that delegates to IEventBus.
Dispatch Methods
Section titled “Dispatch Methods”dispatch
Section titled “dispatch”default <KeyType, EventType extends IEvent<KeyType>> EventType dispatch(@Nonnull Class<EventType> eventClass)Dispatches a synchronous event with no key and no pre-constructed event instance. Equivalent to dispatchFor(eventClass, null).dispatch(null). Returns the event instance after all listeners have processed it.
dispatchAsync
Section titled “dispatchAsync”default <EventType extends IAsyncEvent<Void>> CompletableFuture<EventType> dispatchAsync(@Nonnull Class<EventType> eventClass)Dispatches an asynchronous event with a Void key. Returns a CompletableFuture that completes after all async listeners in the chain have processed the event.
dispatchFor
Section titled “dispatchFor”default <KeyType, EventType extends IEvent<KeyType>> IEventDispatcher<EventType, EventType> dispatchFor( @Nonnull Class<? super EventType> eventClass)Returns an IEventDispatcher for the given event class with no key filter. Call dispatch(event) on the returned dispatcher to fire the event.
<KeyType, EventType extends IEvent<KeyType>> IEventDispatcher<EventType, EventType> dispatchFor( @Nonnull Class<? super EventType> eventClass, @Nullable KeyType key)Returns an IEventDispatcher for the given event class filtered to a specific key. Only listeners registered for this key (or global listeners) will receive the event.
dispatchForAsync
Section titled “dispatchForAsync”default <KeyType, EventType extends IAsyncEvent<KeyType>> IEventDispatcher<EventType, CompletableFuture<EventType>> dispatchForAsync( @Nonnull Class<? super EventType> eventClass)Returns an async IEventDispatcher for the given event class with no key filter.
<KeyType, EventType extends IAsyncEvent<KeyType>> IEventDispatcher<EventType, CompletableFuture<EventType>> dispatchForAsync( @Nonnull Class<? super EventType> eventClass, @Nullable KeyType key)Returns an async IEventDispatcher for the given event class filtered to a specific key.
IEventDispatcher
Section titled “IEventDispatcher”The dispatchFor and dispatchForAsync methods return an IEventDispatcher:
public interface IEventDispatcher<EventType extends IBaseEvent, ReturnType> { default boolean hasListener() { return true; } ReturnType dispatch(@Nullable EventType event);}hasListener()— returnstrueif at least one listener is registered for this event/key combination. Can be used to skip event construction when no listeners exist.dispatch(event)— fires the event to all matching listeners and returns the result (the event itself for sync, aCompletableFuturefor async).
Dispatch Patterns
Section titled “Dispatch Patterns”The server uses two main dispatch patterns:
Simple dispatch (no pre-constructed event)
Section titled “Simple dispatch (no pre-constructed event)”// Server fires BootEvent -- no event instance needed upfronteventBus.dispatch(BootEvent.class);Keyed dispatch with pre-constructed event
Section titled “Keyed dispatch with pre-constructed event”// Server fires a keyed event for a specific keyIEventDispatcher<PlayerReadyEvent, PlayerReadyEvent> dispatcher = eventBus.dispatchFor(PlayerReadyEvent.class, key);
if (dispatcher.hasListener()) { PlayerReadyEvent event = new PlayerReadyEvent(/* ... */); dispatcher.dispatch(event);}The hasListener() check is an optimization — if no listeners are registered, the event object is never constructed.
Inherited from IEventRegistry
Section titled “Inherited from IEventRegistry”This interface inherits all registration methods from IEventRegistry. See EventRegistry for full documentation of each registration family:
register()— synchronous listeners (unkeyed and keyed)registerAsync()— asynchronous listenersregisterGlobal()/registerAsyncGlobal()— listeners for all keysregisterUnhandled()/registerAsyncUnhandled()— fallback listeners
Each family has three overloads: default priority, EventPriority enum, and raw short priority.
Related Types
Section titled “Related Types”- EventRegistry — plugin-scoped proxy that implements
IEventRegistryand delegates toIEventBus - EventRegistration — handle returned by registration methods
- EventPriority — priority enum for listener ordering
IEventRegistry— parent interface defining registration methodsEventBus— concrete implementation (internal)IBaseEvent— base interface for all eventsIEvent— synchronous event interfaceIAsyncEvent— asynchronous event interface- PluginBase — provides
getEventRegistry()for plugin-scoped access - Events Overview — index of all documented events