Contents
Class AsyncEventBusRegistry<KeyType, EventType extends IAsyncEvent<KeyType>>
java.lang.Object
com.hypixel.hytale.event.EventBusRegistry<KeyType, EventType, com.hypixel.hytale.event.AsyncEventBusRegistry.AsyncEventConsumerMap<EventType>>
com.hypixel.hytale.event.AsyncEventBusRegistry<KeyType, EventType>
- Type Parameters:
KeyType- The type of the key used to identify event consumers.EventType- The type of the asynchronous event.
public class AsyncEventBusRegistry<KeyType, EventType extends IAsyncEvent<KeyType>>
extends EventBusRegistry<KeyType, EventType, com.hypixel.hytale.event.AsyncEventBusRegistry.AsyncEventConsumerMap<EventType>>
An asynchronous event bus registry that allows for the registration and dispatching of asynchronous events.
-
Nested Class Summary
Nested classes/interfaces inherited from class EventBusRegistry
EventBusRegistry.EventConsumer, EventBusRegistry.EventConsumerMap<EventType, ConsumerType, ReturnType> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IEventDispatcherA no-operation event dispatcher that simply returns the event without any processing. -
Constructor Summary
ConstructorsConstructorDescriptionAsyncEventBusRegistry(HytaleLogger logger, Class<EventType> eventClass) Default Constructor for aAsyncEventBusRegistryinstance. -
Method Summary
Modifier and TypeMethodDescriptiondispatchFor(KeyType key) Called to get an event dispatcher for the specified key.Called to register an event consumer.registerAsync(short priority, KeyType key, Function<CompletableFuture<EventType>, CompletableFuture<EventType>> function) Called to register an asynchronous event consumer for a specific key.registerAsyncGlobal(short priority, Function<CompletableFuture<EventType>, CompletableFuture<EventType>> function) Registers a global asynchronous event consumer.registerAsyncUnhandled(short priority, Function<CompletableFuture<EventType>, CompletableFuture<EventType>> function) Registers an unhandled asynchronous event consumer.registerGlobal(short priority, Consumer<EventType> consumer) Called to register a global event consumer.registerUnhandled(short priority, Consumer<EventType> consumer) Called to register an unhandled event consumer.Methods inherited from class EventBusRegistry
getEventClass, isAlive, isTimeEvents, setTimeEvents, shutdown
-
Field Details
-
NO_OP
A no-operation event dispatcher that simply returns the event without any processing.
-
-
Constructor Details
-
AsyncEventBusRegistry
Default Constructor for aAsyncEventBusRegistryinstance.- Parameters:
logger- The logger to use for logging events.eventClass- The class of the event type.
-
-
Method Details
-
registerAsync
@Nonnull public EventRegistration<KeyType, EventType> registerAsync(short priority, @Nonnull KeyType key, @Nonnull Function<CompletableFuture<EventType>, CompletableFuture<EventType>> function) Called to register an asynchronous event consumer for a specific key.- Parameters:
priority- The priority of the event consumer.key- The key to register the event consumer for.function- The function that processes the event asynchronously.- Returns:
- an
EventRegistrationrepresenting the registered event consumer.
-
registerAsyncGlobal
@Nonnull public EventRegistration<KeyType, EventType> registerAsyncGlobal(short priority, @Nonnull Function<CompletableFuture<EventType>, CompletableFuture<EventType>> function) Registers a global asynchronous event consumer.- Parameters:
priority- The priority of the event consumer.function- The function that processes the event asynchronously.- Returns:
- an
EventRegistrationrepresenting the registered event consumer.
-
registerAsyncUnhandled
@Nonnull public EventRegistration<KeyType, EventType> registerAsyncUnhandled(short priority, @Nonnull Function<CompletableFuture<EventType>, CompletableFuture<EventType>> function) Registers an unhandled asynchronous event consumer.- Parameters:
priority- The priority of the event consumer.function- The function that processes the event asynchronously.- Returns:
- an
EventRegistrationrepresenting the registered event consumer.
-
register
@Nonnull public EventRegistration<KeyType, EventType> register(short priority, KeyType key, @Nonnull Consumer<EventType> consumer) Description copied from class:EventBusRegistryCalled to register an event consumer.- Specified by:
registerin classEventBusRegistry<KeyType, EventType extends IAsyncEvent<KeyType>, com.hypixel.hytale.event.AsyncEventBusRegistry.AsyncEventConsumerMap<EventType extends IAsyncEvent<KeyType>>>- Parameters:
priority- The priority of the consumer.key- The key to filter events by.consumer- The event consumer.- Returns:
- the event registration.
-
registerGlobal
@Nonnull public EventRegistration<KeyType, EventType> registerGlobal(short priority, @Nonnull Consumer<EventType> consumer) Description copied from class:EventBusRegistryCalled to register a global event consumer.- Specified by:
registerGlobalin classEventBusRegistry<KeyType, EventType extends IAsyncEvent<KeyType>, com.hypixel.hytale.event.AsyncEventBusRegistry.AsyncEventConsumerMap<EventType extends IAsyncEvent<KeyType>>>- Parameters:
priority- The priority of the consumer.consumer- The event consumer.- Returns:
- the event registration.
-
registerUnhandled
@Nonnull public EventRegistration<KeyType, EventType> registerUnhandled(short priority, @Nonnull Consumer<EventType> consumer) Description copied from class:EventBusRegistryCalled to register an unhandled event consumer.- Specified by:
registerUnhandledin classEventBusRegistry<KeyType, EventType extends IAsyncEvent<KeyType>, com.hypixel.hytale.event.AsyncEventBusRegistry.AsyncEventConsumerMap<EventType extends IAsyncEvent<KeyType>>>- Parameters:
priority- The priority of the consumer.consumer- The event consumer.- Returns:
- the event registration.
-
dispatchFor
@Nonnull public IEventDispatcher<EventType, CompletableFuture<EventType>> dispatchFor(@Nullable KeyType key) Description copied from class:EventBusRegistryCalled to get an event dispatcher for the specified key.- Specified by:
dispatchForin classEventBusRegistry<KeyType, EventType extends IAsyncEvent<KeyType>, com.hypixel.hytale.event.AsyncEventBusRegistry.AsyncEventConsumerMap<EventType extends IAsyncEvent<KeyType>>>- Parameters:
key- The key to filter events by.- Returns:
- the event dispatcher.
-