Class EventBus

java.lang.Object
meteordevelopment.orbit.EventBus
All Implemented Interfaces:
IEventBus

public class EventBus extends Object implements IEventBus
Default implementation of IEventBus.
  • Constructor Details

    • EventBus

      public EventBus()
  • Method Details

    • registerLambdaFactory

      public void registerLambdaFactory(String packagePrefix, LambdaListener.Factory factory)
      Description copied from interface: IEventBus
      Registers a lambda factory to use with the specified package.
      Specified by:
      registerLambdaFactory in interface IEventBus
      Parameters:
      packagePrefix - Package prefix that this factory will be used for, eg "meteordevelopment.orbit"
      factory - The factory to use
    • isListening

      public boolean isListening(Class<?> eventKlass)
      Description copied from interface: IEventBus
      Returns whether at least one event listener is currently registered for this event type.
      Specified by:
      isListening in interface IEventBus
      Parameters:
      eventKlass - The event type to check for registered listeners.
      Returns:
      whether the event is being listened for
    • post

      public <T> T post(T event)
      Description copied from interface: IEventBus
      Posts an event to all subscribed event listeners.
      Specified by:
      post in interface IEventBus
      Type Parameters:
      T - Type of the event
      Parameters:
      event - Event to post
      Returns:
      Event passed in
    • post

      public <T extends ICancellable> T post(T event)
      Description copied from interface: IEventBus
      Posts a cancellable event to all subscribed event listeners. Stops after the event was cancelled.
      Specified by:
      post in interface IEventBus
      Type Parameters:
      T - Type of the event
      Parameters:
      event - Event to post
      Returns:
      Event passed in
    • subscribe

      public void subscribe(Object object)
      Description copied from interface: IEventBus
      Finds all correct (static and non-static) methods with EventHandler annotation and subscribes them.
      Specified by:
      subscribe in interface IEventBus
      Parameters:
      object - The object to scan for methods
    • subscribe

      public void subscribe(Class<?> klass)
      Description copied from interface: IEventBus
      Finds all correct (static only) methods with EventHandler annotation and subscribes them.
      Specified by:
      subscribe in interface IEventBus
      Parameters:
      klass - The class to scan for methods
    • subscribe

      public void subscribe(IListener listener)
      Description copied from interface: IEventBus
      Subscribes the listener (both static and non-static).
      Specified by:
      subscribe in interface IEventBus
      Parameters:
      listener - Listener to subscribe
    • unsubscribe

      public void unsubscribe(Object object)
      Description copied from interface: IEventBus
      Finds all correct (static and non-static) methods with EventHandler annotation and unsubscribes them.
      Specified by:
      unsubscribe in interface IEventBus
      Parameters:
      object - The object to scan for methods
    • unsubscribe

      public void unsubscribe(Class<?> klass)
      Description copied from interface: IEventBus
      Finds all correct (static only) methods with EventHandler annotation and unsubscribes them.
      Specified by:
      unsubscribe in interface IEventBus
      Parameters:
      klass - The class to scan for methods
    • unsubscribe

      public void unsubscribe(IListener listener)
      Description copied from interface: IEventBus
      Unsubscribes the listener (both static and non-static).
      Specified by:
      unsubscribe in interface IEventBus
      Parameters:
      listener - Listener to unsubscribe