Package com.velocitypowered.api.event
Interface EventManager
-
public interface EventManager
Allows plugins to register and deregister listeners for event handlers.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <E> CompletableFuture<E>
fire(E event)
Fires the specified event to the event bus asynchronously.default void
fireAndForget(Object event)
Posts the specified event to the event bus and discards the result.default <E> void
register(Object plugin, Class<E> eventClass, EventHandler<E> handler)
Requests that the specifiedhandler
listen for events and associate it with theplugin
.<E> void
register(Object plugin, Class<E> eventClass, PostOrder postOrder, EventHandler<E> handler)
Requests that the specifiedhandler
listen for events and associate it with theplugin
.void
register(Object plugin, Object listener)
Requests that the specifiedlistener
listen for events and associate it with theplugin
.<E> void
unregister(Object plugin, EventHandler<E> handler)
Unregisters a specific event handler for a specific plugin.void
unregisterListener(Object plugin, Object listener)
Unregisters a specific listener for a specific plugin.void
unregisterListeners(Object plugin)
Unregisters all listeners for the specifiedplugin
.
-
-
-
Method Detail
-
register
void register(Object plugin, Object listener)
Requests that the specifiedlistener
listen for events and associate it with theplugin
.- Parameters:
plugin
- the plugin to associate with the listenerlistener
- the listener to register
-
register
default <E> void register(Object plugin, Class<E> eventClass, EventHandler<E> handler)
Requests that the specifiedhandler
listen for events and associate it with theplugin
.- Type Parameters:
E
- the event type to handle- Parameters:
plugin
- the plugin to associate with the handlereventClass
- the class for the event handler to registerhandler
- the handler to register
-
register
<E> void register(Object plugin, Class<E> eventClass, PostOrder postOrder, EventHandler<E> handler)
Requests that the specifiedhandler
listen for events and associate it with theplugin
.- Type Parameters:
E
- the event type to handle- Parameters:
plugin
- the plugin to associate with the handlereventClass
- the class for the event handler to registerpostOrder
- the order in which events should be posted to the handlerhandler
- the handler to register
-
fire
<E> CompletableFuture<E> fire(E event)
Fires the specified event to the event bus asynchronously. This allows Velocity to continue servicing connections while a plugin handles a potentially long-running operation such as a database query.- Parameters:
event
- the event to fire- Returns:
- a
CompletableFuture
representing the posted event
-
fireAndForget
default void fireAndForget(Object event)
Posts the specified event to the event bus and discards the result.- Parameters:
event
- the event to fire
-
unregisterListeners
void unregisterListeners(Object plugin)
Unregisters all listeners for the specifiedplugin
.- Parameters:
plugin
- the plugin to deregister listeners for
-
unregisterListener
void unregisterListener(Object plugin, Object listener)
Unregisters a specific listener for a specific plugin.- Parameters:
plugin
- the plugin associated with the listenerlistener
- the listener to deregister
-
unregister
<E> void unregister(Object plugin, EventHandler<E> handler)
Unregisters a specific event handler for a specific plugin.- Type Parameters:
E
- the event type to handle- Parameters:
plugin
- the plugin to associate with the handlerhandler
- the handler to register
-
-