Annotation Interface ZenEvent


@Target(TYPE) @Retention(RUNTIME) public @interface ZenEvent
Marks a class as being an event accessible 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-bus pairs 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 an event bus:

     
      @ZenCodeType.Name("mods.mymod.event.MyEvent")
      @ZenEvent
      @ZenRegister
      public class MyEvent {
          @ZenEvent.Bus public static final IEventBus<MyEvent> BUS = makeEventBus();
      }
     
 

Note that usage of this annotation enables automatic discovery of the association between event and event bus. In all other cases the type of event carried by the bus must be specified manually: refer to the ZenEvent.Bus documentation for more information.

It is generally customary to use this annotation solely for classes that represent actual events and that contain a single bus. In all other cases, it is preferred to use the ZenEvent.BusCarrier annotation. Note that the single requirement might be strengthened in the future, so prefer using the ZenEvent.BusCarrier annotation for any class containing two or more event buses.

Since:
11.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Marks a field within a class as being an event bus that should be made available to ZenCode scripts, allowing for automatic discovery.
    static @interface 
    Marks a class as carrying a series of IEventBuses that should be made available to ZenCode scripts, allowing for automatic discovery.