Interface IEventBus

All Known Implementing Classes:
EventBus

public interface IEventBus
Manages event listeners.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isListening(Class<?> eventClass)
    Returns whether at least one event listener is currently registered for this event type.
    <T> T
    post(T event)
    Posts an event to all subscribed event listeners.
    void
    Registers a lambda factory to use with the specified package.
    void
    subscribe(Class<?> klass)
    Finds all correct (static only) methods with EventHandler annotation and subscribes them.
    void
    subscribe(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(Class<?> klass)
    Finds all correct (static only) methods with EventHandler annotation and unsubscribes them.
    void
    Finds all correct (static and non-static) methods with EventHandler annotation and unsubscribes them.
    void
    Unsubscribes the listener (both static and non-static).
  • Method Details

    • registerLambdaFactory

      void registerLambdaFactory(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
    • isListening

      boolean isListening(Class<?> eventClass)
      Returns whether at least one event listener is currently registered for this event type.
      Parameters:
      eventClass - The event type to check for registered listeners.
      Returns:
      whether the event is being listened for
      Since:
      0.2.4
    • 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(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(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(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(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