Class Skills

java.lang.Object
de.Keyle.MyPet.api.skill.Skills

public class Skills extends Object
Container holding all Skill instances for a single Pet. Created once per pet (typically when the pet is loaded or spawned), this class instantiates every skill registered with the SkillManager and indexes them by both name and class hierarchy for fast lookup.

Callers retrieve skills via get(String) (by @SkillName value) or get(Class) (by skill class or parent interface), and can check activation state with isActive(String) / isActive(Class).

See Also:
  • Constructor Details

    • Skills

      public Skills(Pet pet)
      Creates a new skill container for the given pet, instantiating all registered skills and indexing them by name and class hierarchy.
      Parameters:
      pet - the pet that owns these skill instances
  • Method Details

    • get

      public Skill get(String skillName)
      Looks up a skill by its SkillName value.
      Parameters:
      skillName - the skill's registered name
      Returns:
      the skill instance, or null if no skill with that name exists
    • get

      public <T extends Skill> T get(Class<T> clazz)
      Looks up a skill by class or parent interface. This allows retrieving a skill via any type in its class hierarchy (e.g. requesting the abstract base class or a marker interface).
      Type Parameters:
      T - the skill type wanted
      Parameters:
      clazz - the skill class or interface to look up
      Returns:
      the matching skill instance, or null if not found
    • all

      public Set<Skill> all()
      Returns all skill instances in this container.
      Returns:
      every skill instance this pet holds
    • getOnHitSkills

      public List<OnHitSkill> getOnHitSkills()
      Immutable list of all skills that implement OnHitSkill.
      Returns:
      the skills that trigger when the pet lands a hit
    • getOnDamageByEntitySkills

      public List<OnDamageByEntitySkill> getOnDamageByEntitySkills()
      Immutable list of all skills that implement OnDamageByEntitySkill.
      Returns:
      the skills that trigger when the pet takes damage
    • getSchedulerSkills

      public List<Scheduler> getSchedulerSkills()
      Immutable list of all skills that implement Scheduler.
      Returns:
      the skills with recurring work to run
    • getNames

      public Set<String> getNames()
      Returns the set of all skill names (from @SkillName annotations).
      Returns:
      the registered names of every skill this pet holds
    • has

      public boolean has(String skillName)
      Returns true if a skill with the given name is registered.
      Parameters:
      skillName - the skill's registered name
      Returns:
      true if the pet holds that skill
    • has

      public boolean has(Class<? extends Skill> clazz)
      Returns true if a skill matching the given class is registered.
      Parameters:
      clazz - the skill type to look for
      Returns:
      true if the pet holds that skill
    • isActive

      public boolean isActive(String skillName)
      Returns true if the named skill exists and is currently active (i.e. has been upgraded at least once and its conditions are met).
      Parameters:
      skillName - the skill's registered name
      Returns:
      true if the skilltree has granted it at the pet's level
    • isActive

      public boolean isActive(Class<? extends Skill> clazz)
      Returns true if the skill matching the given class exists and is currently active.
      Parameters:
      clazz - the skill type to look for
      Returns:
      true if the skilltree has granted it at the pet's level