Class EventUtil

java.lang.Object
kr.toxicity.model.api.util.EventUtil

@Internal public final class EventUtil extends Object
Utility class for dispatching model events.

This class provides helper methods to call events on the BetterModelEventBus and handle cancellable events conveniently.

Since:
2.0.0
  • Method Details

    • call

      @NotNull public static <T extends ModelEvent> BetterModelEventBus.Result call(@NotNull @NotNull Class<T> eventClass, @NotNull @NotNull Supplier<T> eventSupplier)
      Calls an event on the global event bus.
      Type Parameters:
      T - the type of the event
      Parameters:
      eventClass - the class of the event
      eventSupplier - a supplier that creates the event
      Returns:
      the result of the event call
      Since:
      2.0.0
    • call

      public static boolean call(@NotNull @NotNull ModelEvent event)
      Calls an event and checks if it was cancelled.

      If the event is cancellable, this method returns true only if the event was NOT cancelled. If the event is not cancellable, it always returns true.

      Parameters:
      event - the event to call
      Returns:
      true if the event should proceed (not cancelled), false otherwise
      Since:
      2.0.0