Package com.velocitypowered.api.event
Interface EventManager
public interface EventManager
Allows plugins to register and deregister listeners for event handlers.
-
Method Summary
Modifier and TypeMethodDescription<E> CompletableFuture<E>fire(E event) Fires the specified event to the event bus asynchronously.default voidfireAndForget(Object event) Posts the specified event to the event bus and discards the result.<E> voidregister(Object plugin, Class<E> eventClass, short postOrder, EventHandler<E> handler) Requests that the specifiedhandlerlisten for events and associate it with theplugin.default <E> voidregister(Object plugin, Class<E> eventClass, EventHandler<E> handler) Requests that the specifiedhandlerlisten for events and associate it with theplugin.<E> voidregister(Object plugin, Class<E> eventClass, PostOrder postOrder, EventHandler<E> handler) Deprecated.voidRequests that the specifiedlistenerlisten for events and associate it with theplugin.<E> voidunregister(Object plugin, EventHandler<E> handler) Unregisters a specific event handler for a specific plugin.voidunregisterListener(Object plugin, Object listener) Unregisters a specific listener for a specific plugin.voidunregisterListeners(Object plugin) Unregisters all listeners for the specifiedplugin.
-
Method Details
-
register
Requests that the specifiedlistenerlisten for events and associate it with theplugin.- Parameters:
plugin- the plugin to associate with the listenerlistener- the listener to register
-
register
Requests that the specifiedhandlerlisten 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
@Deprecated <E> void register(Object plugin, Class<E> eventClass, PostOrder postOrder, EventHandler<E> handler) Deprecated.useregister(Object, Class, short, EventHandler)insteadRequests that the specifiedhandlerlisten 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
-
register
Requests that the specifiedhandlerlisten for events and associate it with theplugin.Note that this method will register a non-asynchronous listener by default. If you want to use an asynchronous event handler, return
EventTask.async(Runnable)from the handler.- 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 relative order in which events should be posted to the handler. The higher the priority, the earlier the event handler will be calledhandler- the handler to register
-
fire
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
CompletableFuturerepresenting the posted event
-
fireAndForget
Posts the specified event to the event bus and discards the result.- Parameters:
event- the event to fire
-
unregisterListeners
Unregisters all listeners for the specifiedplugin.- Parameters:
plugin- the plugin to deregister listeners for
-
unregisterListener
Unregisters a specific listener for a specific plugin.- Parameters:
plugin- the plugin associated with the listenerlistener- the listener to deregister
-
unregister
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
-
register(Object, Class, short, EventHandler)instead