Interface EventManager


public interface EventManager
Manages the registration of event listeners and the dispatching of events.
  • Method Details

    • registerListener

      <E extends Event> EventManager registerListener(EventListenerRegistration<E> registration)
      Submits a new listener registration to this manager.
      Type Parameters:
      E - The event type
      Parameters:
      registration - The registration
      Returns:
      This manager, for fluency
    • registerListeners

      @Deprecated(since="13") EventManager registerListeners(org.spongepowered.plugin.PluginContainer plugin, Object obj)
      Deprecated.
      In order to be compatible with the JPMS, it is highly recommended that plugins instead use the registerListeners(PluginContainer, Object, MethodHandles.Lookup) overload.
      Registers Event methods annotated with @Listener in the specified object.

      This will not include any methods declared in supertypes, but will test for private and package-private listener methods.

      Parameters:
      plugin - The plugin container
      obj - The object
      Returns:
      This manager, for fluency
    • registerListeners

      EventManager registerListeners(org.spongepowered.plugin.PluginContainer plugin, Object obj, MethodHandles.Lookup lookup)
      Registers Event methods annotated with @Listener in the specified object.

      This will not include any methods declared in supertypes, but will test for private and package-private listener methods.

      The provided lookup will be used for privileged access to the listener object.

      Parameters:
      plugin - The plugin container
      obj - The object
      lookup - The lookup with which to access the listener object
      Returns:
      This manager, for fluency
    • unregisterListeners

      EventManager unregisterListeners(Object obj)
      Un-registers an object from receiving Events.

      If the provided object is a plugin, all events associated with that plugin will be unregistered.

      Parameters:
      obj - The object
      Returns:
      This manager, for fluency
    • post

      boolean post(Event event)
      Calls an Event to all listeners that listen to it.
      Parameters:
      event - The event
      Returns:
      True if cancelled, false if not