Class EventInvokerImpl<T>

java.lang.Object
net.ixdarklord.coolcatcore.internal.event.EventInvokerImpl<T>
All Implemented Interfaces:
EventInvoker<T>

public final class EventInvokerImpl<T> extends Object implements EventInvoker<T>
  • Method Details

    • create

      public static <T> EventInvoker<T> create(Class<T> type, @Nullable @Nullable Function<List<T>,T> combiner)
    • lookup

      public static <T> EventInvoker<T> lookup(Class<T> type)
    • type

      public Class<T> type()
      Description copied from interface: EventInvoker
      The listener type identifying this event.
      Specified by:
      type in interface EventInvoker<T>
    • register

      public void register(EventPhase phase, T listener)
      Description copied from interface: EventInvoker
      Adds a listener in the given phase. For events whose loader hook fires each EventPhase.Band at its own place, EventPhase.FIRST also runs before other mods' own listeners of the game event and EventPhase.LAST after them.
      Specified by:
      register in interface EventInvoker<T>
    • unregister

      public boolean unregister(T listener)
      Description copied from interface: EventInvoker
      Removes a listener, from whichever phase it was added to.
      Specified by:
      unregister in interface EventInvoker<T>
      Returns:
      whether it was registered
    • hasListeners

      public boolean hasListeners()
      Specified by:
      hasListeners in interface EventInvoker<T>
      Returns:
      whether the event has any listeners, so a loader can skip building its arguments
    • hasListeners

      public boolean hasListeners(EventPhase.Band band)
      Specified by:
      hasListeners in interface EventInvoker<T>
      Returns:
      whether the event has listeners in phases of this band
    • invoker

      public T invoker()
      Description copied from interface: EventInvoker
      Fires the event: calls every listener as the event combines them.
      Specified by:
      invoker in interface EventInvoker<T>
    • invoker

      public T invoker(EventPhase.Band band)
      Description copied from interface: EventInvoker
      Fires the event for the listeners of one band only, in phase order: what a loader hook calls from each of its places (before, among and after other mods' listeners). The three bands together are EventInvoker.invoker().
      Specified by:
      invoker in interface EventInvoker<T>