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> java.util.concurrent.CompletableFuture<E> fire​(E event)
      Fires the specified event to the event bus asynchronously.
      default void fireAndForget​(java.lang.Object event)
      Posts the specified event to the event bus and discards the result.
      <E> void register​(java.lang.Object plugin, java.lang.Class<E> eventClass, short postOrder, EventHandler<E> handler)
      Requests that the specified handler listen for events and associate it with the plugin.
      default <E> void register​(java.lang.Object plugin, java.lang.Class<E> eventClass, EventHandler<E> handler)
      Requests that the specified handler listen for events and associate it with the plugin.
      void register​(java.lang.Object plugin, java.lang.Object listener)
      Requests that the specified listener listen for events and associate it with the plugin.
      <E> void unregister​(java.lang.Object plugin, EventHandler<E> handler)
      Unregisters a specific event handler for a specific plugin.
      void unregisterListener​(java.lang.Object plugin, java.lang.Object listener)
      Unregisters a specific listener for a specific plugin.
      void unregisterListeners​(java.lang.Object plugin)
      Unregisters all listeners for the specified plugin.
    • Method Detail

      • register

        void register​(java.lang.Object plugin,
                      java.lang.Object listener)
        Requests that the specified listener listen for events and associate it with the plugin.
        Parameters:
        plugin - the plugin to associate with the listener
        listener - the listener to register
      • register

        default <E> void register​(java.lang.Object plugin,
                                  java.lang.Class<E> eventClass,
                                  EventHandler<E> handler)
        Requests that the specified handler listen for events and associate it with the plugin.
        Type Parameters:
        E - the event type to handle
        Parameters:
        plugin - the plugin to associate with the handler
        eventClass - the class for the event handler to register
        handler - the handler to register
      • register

        <E> void register​(java.lang.Object plugin,
                          java.lang.Class<E> eventClass,
                          short postOrder,
                          EventHandler<E> handler)
        Requests that the specified handler listen for events and associate it with the plugin.
        Type Parameters:
        E - the event type to handle
        Parameters:
        plugin - the plugin to associate with the handler
        eventClass - the class for the event handler to register
        postOrder - the order in which events should be posted to the handler
        handler - the handler to register
      • fire

        <E> java.util.concurrent.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​(java.lang.Object event)
        Posts the specified event to the event bus and discards the result.
        Parameters:
        event - the event to fire
      • unregisterListeners

        void unregisterListeners​(java.lang.Object plugin)
        Unregisters all listeners for the specified plugin.
        Parameters:
        plugin - the plugin to deregister listeners for
      • unregisterListener

        void unregisterListener​(java.lang.Object plugin,
                                java.lang.Object listener)
        Unregisters a specific listener for a specific plugin.
        Parameters:
        plugin - the plugin associated with the listener
        listener - the listener to deregister
      • unregister

        <E> void unregister​(java.lang.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 handler
        handler - the handler to register