Class EventManager
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispatch(@NotNull CCEventType<Void> event) Dispatches a Void event to its listeners and stores it in a temporary log.<T> voiddispatch(@NotNull CCEventType<T> event, T body) Dispatches an event to its listeners and stores it in a temporary log.<T> voidregisterEventConsumer(@NotNull CCEventType<T> event, @NotNull Consumer<T> listener) Registers a listener to be called as appropriate.<T> voidregisterEventConsumer(@NotNull CCEventType<T> event, @NotNull Consumer<T> listener, int catchUpPeriod) Registers a listener to be called as appropriate.voidregisterEventRunnable(@NotNull CCEventType<?> event, @NotNull Runnable listener) Registers a listener to be called as appropriate.voidregisterEventRunnable(@NotNull CCEventType<?> event, @NotNull Runnable listener, int catchUpPeriod) Registers a listener to be called as appropriate.
-
Field Details
-
CATCH_UP_DEFAULT
public static final int CATCH_UP_DEFAULT- See Also:
-
RECORD_LIMIT
public static final int RECORD_LIMIT- See Also:
-
-
Constructor Details
-
EventManager
Create an EventManager.- Parameters:
parent- Crowd Control instance
-
-
Method Details
-
dispatch
Dispatches an event to its listeners and stores it in a temporary log.- Parameters:
event- event typebody- body to pass onto listeners
-
dispatch
Dispatches a Void event to its listeners and stores it in a temporary log.- Parameters:
event- event type
-
registerEventConsumer
public <T> void registerEventConsumer(@NotNull @NotNull CCEventType<T> event, @NotNull @NotNull Consumer<T> listener, int catchUpPeriod) Registers a listener to be called as appropriate.catchUpPerioddetermines the time in seconds in which to look for recently sent events to catch the listener up on events it just missed. Set to 0 to disable, or -1 to fetch all records (within the 100 most recent).- Parameters:
event- the type of event to register forlistener- the function to call as necessarycatchUpPeriod- duration in seconds or -1
-
registerEventConsumer
public <T> void registerEventConsumer(@NotNull @NotNull CCEventType<T> event, @NotNull @NotNull Consumer<T> listener) Registers a listener to be called as appropriate.If this event has recently been dispatched, then your listener will immediately be invoked. See
registerEventConsumer(CCEventType, Consumer, int)for more information on the catch-up period.- Parameters:
event- the type of event to register forlistener- the function to call as necessary
-
registerEventRunnable
public void registerEventRunnable(@NotNull @NotNull CCEventType<?> event, @NotNull @NotNull Runnable listener, int catchUpPeriod) Registers a listener to be called as appropriate.catchUpPerioddetermines the time in seconds in which to look for recently sent events to catch the listener up on events it just missed. Set to 0 to disable, or -1 to fetch all records (within the 100 most recent).- Parameters:
event- the type of event to register forlistener- the function to call as necessarycatchUpPeriod- duration in seconds or -1
-
registerEventRunnable
public void registerEventRunnable(@NotNull @NotNull CCEventType<?> event, @NotNull @NotNull Runnable listener) Registers a listener to be called as appropriate.If this event has recently been dispatched, then your listener will immediately be invoked. See
registerEventRunnable(CCEventType, Runnable, int)for more information on the catch-up period.- Parameters:
event- the type of event to register forlistener- the function to call as necessary
-