类 EventListenerGroupImpl.EventListenerCollectorImpl

java.lang.Object
net.neoforged.testframework.impl.EventListenerGroupImpl.EventListenerCollectorImpl
所有已实现的接口:
Test.EventListenerGroup.EventListenerCollector
封闭类:
EventListenerGroupImpl

private static final class EventListenerGroupImpl.EventListenerCollectorImpl extends Object implements Test.EventListenerGroup.EventListenerCollector
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private final List<Consumer<net.neoforged.bus.api.IEventBus>>
     
    private final List<Object>
     
  • 构造器概要

    构造器
    限定符
    构造器
    说明
    private
     
  • 方法概要

    修饰符和类型
    方法
    说明
    <T extends net.neoforged.bus.api.Event>
    void
    addListener(net.neoforged.bus.api.EventPriority priority, boolean receiveCancelled, Class<T> eventType, Consumer<T> consumer)
    Add a consumer listener with the specified EventPriority and potentially cancelled events.
    <T extends net.neoforged.bus.api.Event>
    void
    addListener(net.neoforged.bus.api.EventPriority priority, boolean receiveCancelled, Consumer<T> consumer)
    Add a consumer listener with the specified EventPriority and potentially cancelled events.
    void
    register(Object object)
    Register an instance object or a Class, and add listeners for all SubscribeEvent annotated methods found there.
    void
    registerAll(net.neoforged.bus.api.IEventBus bus)
    Registers all the listeners added through this collector.
    void
    unregisterAll(net.neoforged.bus.api.IEventBus bus)
    Unregisters all the listeners added through this collector.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    从接口继承的方法 net.neoforged.testframework.Test.EventListenerGroup.EventListenerCollector

    addListener
  • 字段详细资料

    • subscribeActions

      private final List<Consumer<net.neoforged.bus.api.IEventBus>> subscribeActions
    • subscribers

      private final List<Object> subscribers
  • 构造器详细资料

    • EventListenerCollectorImpl

      private EventListenerCollectorImpl()
  • 方法详细资料

    • register

      public void register(Object object)
      Register an instance object or a Class, and add listeners for all SubscribeEvent annotated methods found there.

      Depending on what is passed as an argument, different listener creation behaviour is performed.

      Object Instance
      Scanned for non-static methods annotated with SubscribeEvent and creates listeners for each method found.
      Class Instance
      Scanned for static methods annotated with SubscribeEvent and creates listeners for each method found.
      指定者:
      register 在接口中 Test.EventListenerGroup.EventListenerCollector
      参数:
      object - either a Class instance or an arbitrary object, for scanning and event listener creation
    • addListener

      public <T extends net.neoforged.bus.api.Event> void addListener(net.neoforged.bus.api.EventPriority priority, boolean receiveCancelled, Class<T> eventType, Consumer<T> consumer)
      Add a consumer listener with the specified EventPriority and potentially cancelled events.
      Use this method when one of the other methods fails to determine the concrete Event subclass that is intended to be subscribed to.
      指定者:
      addListener 在接口中 Test.EventListenerGroup.EventListenerCollector
      类型参数:
      T - the Event subclass to listen for
      参数:
      priority - the priority of the listener
      receiveCancelled - indicate if this listener should receive events that have been ICancellableEvent cancelled
      eventType - the concrete Event subclass to subscribe to
      consumer - callback to invoke when a matching event is received
    • addListener

      public <T extends net.neoforged.bus.api.Event> void addListener(net.neoforged.bus.api.EventPriority priority, boolean receiveCancelled, Consumer<T> consumer)
      Add a consumer listener with the specified EventPriority and potentially cancelled events.
      指定者:
      addListener 在接口中 Test.EventListenerGroup.EventListenerCollector
      类型参数:
      T - the Event subclass to listen for
      参数:
      priority - the priority of the listener
      receiveCancelled - indicate if this listener should receive events that have been ICancellableEvent cancelled
      consumer - callback to invoke when a matching event is received
    • unregisterAll

      public void unregisterAll(net.neoforged.bus.api.IEventBus bus)
      Unregisters all the listeners added through this collector.
      指定者:
      unregisterAll 在接口中 Test.EventListenerGroup.EventListenerCollector
      参数:
      bus - the bus to unregister from
    • registerAll

      public void registerAll(net.neoforged.bus.api.IEventBus bus)
      Registers all the listeners added through this collector.
      指定者:
      registerAll 在接口中 Test.EventListenerGroup.EventListenerCollector
      参数:
      bus - the bus to register