Class SectionTypeRegistry

java.lang.Object
de.Keyle.MyPet.api.gui.SectionTypeRegistry

public final class SectionTypeRegistry extends Object
Process-wide registry of SectionTypes by id. Section type-holder classes self-register via SectionType.register(java.lang.String, java.lang.Class<S>, de.Keyle.MyPet.api.gui.SectionRenderer<S>, de.Keyle.MyPet.api.gui.JsonCodec<S>) in their static initializers. ensureBuiltinsRegistered() forces every built-in type-holder class to load so the registry is fully populated before the loader runs.
  • Method Details

    • register

      public static void register(SectionType<?> type)
      Registers a section type under its own id.
      Parameters:
      type - the section type to register
      Throws:
      IllegalStateException - if a different type is already registered under that id
    • byId

      public static Optional<SectionType<?>> byId(String id)
      Looks a section type up by id.
      Parameters:
      id - the type id as it appears in menu JSON
      Returns:
      the registered type, or empty if nothing is registered under that id
    • all

      public static Map<String,SectionType<?>> all()
      Returns every registered section type.
      Returns:
      an immutable copy of the registry, keyed by type id
    • ensureBuiltinsRegistered

      public static void ensureBuiltinsRegistered()
      Force-load every built-in section type-holder class so its static initializer registers the type. Idempotent. Called from MyPetPlugin.onLoad.