Interface IEventBus

  • All Known Implementing Classes:
    EventBus

    public interface IEventBus
    Manages event listeners.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T post​(T event)
      Posts an event to all subscribed event listeners.
      void registerLambdaFactory​(java.lang.String packagePrefix, LambdaListener.Factory factory)
      Registers a lambda factory to use with the specified package.
      void subscribe​(java.lang.Class<?> klass)
      Finds all correct (static only) methods with EventHandler annotation and subscribes them.
      void subscribe​(java.lang.Object object)
      Finds all correct (static and non-static) methods with EventHandler annotation and subscribes them.
      void subscribe​(IListener listener)
      Subscribes the listener (both static and non-static).
      void unsubscribe​(java.lang.Class<?> klass)
      Finds all correct (static only) methods with EventHandler annotation and unsubscribes them.
      void unsubscribe​(java.lang.Object object)
      Finds all correct (static and non-static) methods with EventHandler annotation and unsubscribes them.
      void unsubscribe​(IListener listener)
      Unsubscribes the listener (both static and non-static).
    • Method Detail

      • registerLambdaFactory

        void registerLambdaFactory​(java.lang.String packagePrefix,
                                   LambdaListener.Factory factory)
        Registers a lambda factory to use with the specified package.
        Parameters:
        packagePrefix - Package prefix that this factory will be used for, eg "meteordevelopment.orbit"
        factory - The factory to use
      • post

        <T> T post​(T event)
        Posts an event to all subscribed event listeners.
        Type Parameters:
        T - Type of the event
        Parameters:
        event - Event to post
        Returns:
        Event passed in
      • post

        <T extends ICancellable> T post​(T event)
        Posts a cancellable event to all subscribed event listeners. Stops after the event was cancelled.
        Type Parameters:
        T - Type of the event
        Parameters:
        event - Event to post
        Returns:
        Event passed in
      • subscribe

        void subscribe​(java.lang.Object object)
        Finds all correct (static and non-static) methods with EventHandler annotation and subscribes them.
        Parameters:
        object - The object to scan for methods
      • subscribe

        void subscribe​(java.lang.Class<?> klass)
        Finds all correct (static only) methods with EventHandler annotation and subscribes them.
        Parameters:
        klass - The class to scan for methods
      • subscribe

        void subscribe​(IListener listener)
        Subscribes the listener (both static and non-static).
        Parameters:
        listener - Listener to subscribe
      • unsubscribe

        void unsubscribe​(java.lang.Object object)
        Finds all correct (static and non-static) methods with EventHandler annotation and unsubscribes them.
        Parameters:
        object - The object to scan for methods
      • unsubscribe

        void unsubscribe​(java.lang.Class<?> klass)
        Finds all correct (static only) methods with EventHandler annotation and unsubscribes them.
        Parameters:
        klass - The class to scan for methods
      • unsubscribe

        void unsubscribe​(IListener listener)
        Unsubscribes the listener (both static and non-static).
        Parameters:
        listener - Listener to unsubscribe