Package de.Keyle.MyPet.api.lifecycle
Class PetLifecycleHookRegistry
java.lang.Object
de.Keyle.MyPet.api.lifecycle.PetLifecycleHookRegistry
Central registry of every
PetLifecycleHook declared as a static
field on a pet class. Populated as a side effect of each hook's
constructor, which fires during the pet class's <clinit>.
forPet(Pet) returns the hooks registered for the given pet's
type — shared spawn/despawn code in PetImpl, VanillaMobSpawner,
and PetManager iterates the result without naming any specific pet
type. Adding a new pet-specific lifecycle hook is a one-line declaration
on the pet class; no shared file is touched.
ensurePetsLoaded() force-initializes every registered pet
class via Class.forName(true) so the registry is fully populated
before the first spawn-side iteration.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidForce-initializes every registered pet class viaClass.forName(true)so each one's staticPetLifecycleHookfield initializers fire and register with this registry.static List<PetLifecycleHook> Returns every lifecycle hook registered forpet's type, in registration order.
-
Method Details
-
ensurePetsLoaded
public static void ensurePetsLoaded()Force-initializes every registered pet class viaClass.forName(true)so each one's staticPetLifecycleHookfield initializers fire and register with this registry. Idempotent; runs once per JVM. -
forPet
Returns every lifecycle hook registered forpet's type, in registration order. Returns an empty list when no hook is registered.- Parameters:
pet- the pet whose type to look up- Returns:
- the hooks to run for that pet, global hooks included
-