Class WildAngerCheck<T extends Mob>

java.lang.Object
de.Keyle.MyPet.api.entity.leashing.WildAngerCheck<T>
Type Parameters:
T - the Bukkit mob type this check applies to

public final class WildAngerCheck<T extends Mob> extends Object
Per-species predicate that decides whether a wild Bukkit mob is currently "angry" — consumed by capture-time leash flags (see AngryFlag). Wraps the species-specific Bukkit API (e.g. Wolf#isAngry, Bee#getAnger, Warden#getAngerLevel) so callers can ask without an instanceof chain.

Declared as a static field on the matching PetXxx class:


 public static final WildAngerCheck<Wolf> ANGER_CHECK =
     new WildAngerCheck<>(Wolf.class, Wolf::isAngry);
 

Note the semantic inversion vs. other per-pet handles: this describes the wild mob's state before it becomes a pet, not the pet's own runtime state. The pet class is still the right declaration site because it is v4's single source of truth for everything species-specific.

Construction self-registers with WildAngerCheckRegistry; the leash-flag check looks the entry up via WildAngerCheckRegistry.forEntity(org.bukkit.entity.LivingEntity).

  • Constructor Details

    • WildAngerCheck

      public WildAngerCheck(Class<T> mobClass, Predicate<T> predicate)
      Declares an anger check for one mob type, registering itself as it is built.
      Parameters:
      mobClass - the Bukkit mob class this check applies to
      predicate - decides whether such a mob is currently angry
  • Method Details

    • mobClass

      public Class<T> mobClass()
      Returns the mob type this check applies to.
      Returns:
      the Bukkit mob class
    • test

      public boolean test(LivingEntity entity)
      Runs the check. The entity must be an instance of mobClass().
      Parameters:
      entity - the mob to test
      Returns:
      true if the mob is currently angry