Class EventHandler

java.lang.Object
com.hypixel.hytale.builtin.worldgen.modifier.EventHandler
All Implemented Interfaces:
AutoCloseable

public final class EventHandler extends Object implements AutoCloseable
Coordinates world-generation modifier handling for a specific world-gen content root.

This class gathers applicable WorldGenModifiers, orders them by pack priority and modifier order, groups them by event type, and applies their operations when matching modification events are dispatched. It also manages a thread-local scoped handler so modifier processing can be opened for a loading context and automatically cleared when that scope is closed.

  • Method Details

    • get

      @Nonnull public EventHandler.Modifier[] get(@Nonnull Content.Type type)
      Retrieves the modifiers for the given event type.
      Parameters:
      type - The event type to retrieve modifiers for.
      Returns:
      The modifiers for the given event type or an empty array if none are found.
    • close

      public void close()
      Releases the EventHandler and clears all internal state.
      Specified by:
      close in interface AutoCloseable
    • handle

      public static <T> void handle(@Nonnull ModifyEvent<T> event)
      Generic event handler for instances of ModifyEvent.
      Type Parameters:
      T - The type of content to be modified.
      Parameters:
      event - The event to handle.
    • acquire

      public static EventHandler acquire(@Nonnull Path root)
      Creates a new EventHandler for the given world-gen content root. The returned value should be held within a try-with-resources block to ensure proper resource cleanup.
      Parameters:
      root - The root path of the content to be modified.
      Returns:
      The newly opened modifier handler.