Package de.Keyle.MyPet.api.skill
Class Skills
java.lang.Object
de.Keyle.MyPet.api.skill.Skills
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionall()Returns all skill instances in this container.<T extends Skill>
TLooks up a skill by class or parent interface.Looks up a skill by itsSkillNamevalue.getNames()Returns the set of all skill names (from@SkillNameannotations).Immutable list of all skills that implementOnDamageByEntitySkill.Immutable list of all skills that implementOnHitSkill.Immutable list of all skills that implementScheduler.booleanReturnstrueif a skill matching the given class is registered.booleanReturnstrueif a skill with the given name is registered.booleanReturnstrueif the skill matching the given class exists and is currently active.booleanReturnstrueif the named skill exists and is currently active (i.e.
-
Constructor Details
-
Skills
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
Looks up a skill by itsSkillNamevalue.- Parameters:
skillName- the skill's registered name- Returns:
- the skill instance, or
nullif no skill with that name exists
-
get
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
nullif not found
-
all
Returns all skill instances in this container.- Returns:
- every skill instance this pet holds
-
getOnHitSkills
Immutable list of all skills that implementOnHitSkill.- Returns:
- the skills that trigger when the pet lands a hit
-
getOnDamageByEntitySkills
Immutable list of all skills that implementOnDamageByEntitySkill.- Returns:
- the skills that trigger when the pet takes damage
-
getSchedulerSkills
Immutable list of all skills that implementScheduler.- Returns:
- the skills with recurring work to run
-
getNames
Returns the set of all skill names (from@SkillNameannotations).- Returns:
- the registered names of every skill this pet holds
-
has
Returnstrueif a skill with the given name is registered.- Parameters:
skillName- the skill's registered name- Returns:
trueif the pet holds that skill
-
has
Returnstrueif a skill matching the given class is registered.- Parameters:
clazz- the skill type to look for- Returns:
trueif the pet holds that skill
-
isActive
Returnstrueif 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:
trueif the skilltree has granted it at the pet's level
-
isActive
Returnstrueif the skill matching the given class exists and is currently active.- Parameters:
clazz- the skill type to look for- Returns:
trueif the skilltree has granted it at the pet's level
-