Class WildAngerCheckRegistry
java.lang.Object
de.Keyle.MyPet.api.entity.leashing.WildAngerCheckRegistry
Central registry of every
WildAngerCheck declared as a static
field on a pet class. Populated as a side effect of each check's
constructor, which fires during the pet class's <clinit>.
forEntity(LivingEntity) returns the check registered for the
given entity's species, or Optional.empty() if no pet class
declares one. AngryFlag iterates the result without naming any
specific pet type; adding a new angerable species is a one-line static
field on its pet class.
ensurePetsLoaded() force-initializes every registered pet
class via Class.forName(true) so the registry is fully populated
before the first lookup.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidForce-initializes every registered pet class viaClass.forName(true)so each one's staticWildAngerCheckfield initializers fire and register with this registry.static Optional<WildAngerCheck<?>> forEntity(LivingEntity entity) Returns the anger check registered forentity's species, orOptional.empty()if no pet class declares one (either the species isn't a MyPet pet type, or its pet class doesn't expose anger semantics).
-
Method Details
-
ensurePetsLoaded
public static void ensurePetsLoaded()Force-initializes every registered pet class viaClass.forName(true)so each one's staticWildAngerCheckfield initializers fire and register with this registry. Idempotent; runs once per JVM. -
forEntity
Returns the anger check registered forentity's species, orOptional.empty()if no pet class declares one (either the species isn't a MyPet pet type, or its pet class doesn't expose anger semantics).- Parameters:
entity- the mob whose species to look up- Returns:
- the check for that species, or empty if none is declared
-