Annotation Interface ZenEvent.BusCarrier
- Enclosing class:
- ZenEvent
IEventBuses that should
be made available to ZenCode scripts, allowing for automatic discovery.
Every class annotated with this annotation will be automatically discovered by CraftTweaker and managed
accordingly. Namely, CraftTweaker will automatically manage registration of event buses and events during the
IEventRegistrationHandler phase of plugin loading.
A class annotated by this annotation must contain at least one public static final
field of type IEventBus annotated with the ZenEvent.Bus
annotation. All fields that respect these characteristics will be discovered and automatically registered as
known event buses by CraftTweaker. As an example, the following snippet of code shows the conventional way of
registering multiple event buses:
@ZenEvent.BusCarrier
public final class MyEvents {
@ZenEvent.Bus(FooEvent.class) public static final IEventBus<FooEvent> FOO_BUS = makeBus(FooEvent.class);
@ZenEvent.Bus(BarEvent.class) public static final IEventBus<BarEvent> BAR_BUS = makeBus(BarEvent.class);
@ZenEvent.Bus(BazEvent.class) public static final IEventBus<BazEvent> BAZ_BUS = makeBus(BazEvent.class);
}
Note that usage of this annotation does not allow for automatic discovery of the association between event and
event bus. The type of event carried by the bus must then be always specified manually. Refer to the
ZenEvent.Bus documentation for more information.
It is generally customary to use this annotation solely on classes that are mere event bus carriers and do
not represent events themselves. In such a case, it is suggested to use the ZenEvent
annotation directly.
- Since:
- 11.0.0