Package de.Keyle.MyPet.api.gui
Class SectionTypeRegistry
java.lang.Object
de.Keyle.MyPet.api.gui.SectionTypeRegistry
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 Summary
Modifier and TypeMethodDescriptionstatic Map<String, SectionType<?>> all()Returns every registered section type.static Optional<SectionType<?>> Looks a section type up by id.static voidForce-load every built-in section type-holder class so its static initializer registers the type.static voidregister(SectionType<?> type) Registers a section type under its own id.
-
Method Details
-
register
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
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
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.
-