Class EventRegistry

java.lang.Object
dev.adlin.vts4j.event.EventRegistry

public class EventRegistry extends Object
A registry that provides bidirectional mapping between unique event string identifiers and their respective Event class types.

This registry is primarily used to resolve event classes during network serialization and request dispatching.

  • Constructor Details

    • EventRegistry

      public EventRegistry()
  • Method Details

    • getEventClass

      public static @Nullable Class<? extends Event> getEventClass(@NonNull RequestType requestType)
      Resolves the Event class associated with the string representation of a request type.
      Parameters:
      requestType - the request type to resolve from
      Returns:
      the associated Event class, or null if no mapping exists
    • getEventClass

      public static @Nullable Class<? extends Event> getEventClass(@NonNull String eventName)
      Resolves the Event class associated with the provided unique event name.
      Parameters:
      eventName - the string identifier of the event
      Returns:
      the associated Event class, or null if no mapping exists
    • exists

      public static boolean exists(@NonNull Class<? extends Event> eventClass)
      Checks if the specified event class is registered.
      Parameters:
      eventClass - the event class to verify
      Returns:
      true if the class is registered, false otherwise
    • exists

      public static boolean exists(@NonNull String eventName)
      Checks if the specified event name identifier is registered.
      Parameters:
      eventName - the string identifier to verify
      Returns:
      true if the name is registered, false otherwise
    • getName

      public static @Nullable String getName(@NonNull Class<? extends Event> eventClass)
      Retrieves the unique string name identifier for the given event class.
      Parameters:
      eventClass - the registered event class
      Returns:
      the string identifier associated with the class, or null if not found