Skip to content

IEventBus

Package: com.hypixel.hytale.event

public interface IEventBus extends IEventRegistry

The 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.

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.

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.

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.

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.

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.

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() — returns true if 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, a CompletableFuture for async).

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 upfront
eventBus.dispatch(BootEvent.class);
// Server fires a keyed event for a specific key
IEventDispatcher<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.

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 listeners
  • registerGlobal() / registerAsyncGlobal() — listeners for all keys
  • registerUnhandled() / registerAsyncUnhandled() — fallback listeners

Each family has three overloads: default priority, EventPriority enum, and raw short priority.

  • EventRegistry — plugin-scoped proxy that implements IEventRegistry and delegates to IEventBus
  • EventRegistration — handle returned by registration methods
  • EventPriority — priority enum for listener ordering
  • IEventRegistry — parent interface defining registration methods
  • EventBus — concrete implementation (internal)
  • IBaseEvent — base interface for all events
  • IEvent — synchronous event interface
  • IAsyncEvent — asynchronous event interface
  • PluginBase — provides getEventRegistry() for plugin-scoped access
  • Events Overview — index of all documented events