Class Skilltree
A skilltree contains a set of Upgrade entries gated by LevelRules. When a pet
reaches a new level, each rule is checked and the matching upgrades are applied to the pet's
skills. Skilltrees may also inherit from another skilltree so that common progressions can be
shared without duplication.
Additional metadata includes:
- Display name / description -- shown to the player in the skilltree selection GUI
- Icon -- the
SkilltreeIconrendered in inventory menus - Mob types -- which pet types can use this skilltree
- Weight -- relative probability when randomly assigning a skilltree
- Order -- display ordering in lists and menus
- Requirements -- conditions (permissions, economy, etc.) the pet must satisfy
- Max level / required level -- bounds on when this tree is available and active
Skilltrees are loaded from .st.json files by the plugin's loader and registered with
the SkilltreeManager.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final recordA level-gated notification binding.protected static final recordA level-gated upgrade binding. -
Field Summary
FieldsModifier and TypeFieldDescriptionLore lines shown in the selection menu.protected StringName shown to players, ornullto usegetName().protected SkilltreeIconIcon shown in the selection menu, ornullfor the default.protected StringName of the skilltree this one inherits upgrades from, ornullwhen it stands alone.protected intHighest level this skilltree grants upgrades for;0means unbounded.Pet types allowed to use this skilltree; empty means all of them.protected final List<Skilltree.NotificationEntry> Level-gated messages shown to the owner.protected intSort position in the selection menu; lower comes first.protected intLevel a pet must reach before it may select this skilltree.Requirement blocks gating who may select this skilltree.protected final StringThis skilltree's unique name, as the file that defines it is called.protected final List<Skilltree.UpgradeEntry> Level-gated upgrades, ordered by rule priority.protected doubleRelative chance of being picked when skilltrees are assigned at random.Per-pet-type overrides ofweight. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDescription(String[] lines) Appends multiple lines to the description.voidaddDescriptionLine(String line) Appends a single line to the description.voidaddNotification(LevelRule levelRule, String notification) Registers a notification message to be displayed when the given level rule matches.voidaddRequirementSettings(Settings settings) Adds a requirement configuration block that will be evaluated by the namedRequirement.voidaddUpgrade(LevelRule levelRule, Upgrade<?> upgrade) Registers an upgrade to be applied whenever the given level rule matches.booleancheckRequirements(Pet pet) Evaluates all configured requirements against the given pet.voidRemoves all description lines.Returns an unmodifiable view of this skilltree's description lines.Returns the display name shown to players, falling back to the internal name if unset.getFailedRequirements(Pet pet) Names of the requirements the pet currently fails, in evaluation order.getIcon()Returns the icon for this skilltree, creating a default one if not yet set.Name of the skilltree this one inherits upgrades from, ornullwhen it stands alone.intReturns the maximum level for this skilltree.Pet types allowed to use this skilltree; empty means all of them.getName()Returns the unique internal name of this skilltree.getNotifications(int level) Collects all notification messages that should be displayed at the given level.intgetOrder()Sort position in the selection menu; lower comes first.intLevel a pet must reach before it may select this skilltree.Requirement blocks gating who may select this skilltree.getUpgrades(int level) Collects all upgrades that should be applied at the given level, including inherited ones.getUpgrades(int level, Set<String> computedSkilltrees) Internal recursive method that collects upgrades while tracking already-visited trees to avoid circular inheritance loops.doubleRandom-assignment weight for the given pet type.booleanReturnstrueif a custom display name has been explicitly set.booleanReturnstrueif this skilltree inherits from another registered skilltree.booleanisAscensionFor(Pet pet) True if this tree's Skilltree requirement names the pet's current tree — i.e.voidremoveDescriptionLine(int index) Removes the description line at the specified index.voidsetDisplayName(String displayName) Name shown to players, ornullto usegetName().voidsetIcon(SkilltreeIcon icon) Icon shown in the selection menu, ornullfor the default.voidsetInheritedSkilltreeName(String inheritedSkilltreeName) Name of the skilltree this one inherits upgrades from, ornullwhen it stands alone.voidsetMaxLevel(int maxLevel) Sets the maximum level for this skilltree, clamped to the global level cap.voidsetMobTypes(Collection<PetType> mobTypes) Replaces the set of pet types that are allowed to use this skilltree.voidsetOrder(int order) Sort position in the selection menu; lower comes first.voidsetRequiredLevel(int requiredLevel) Sets the minimum pet level required before this skilltree becomes available.voidsetWeight(double weight) Default weight used by random assignment when no per-type override exists.voidsetWeightOverride(PetType type, double weight) Per-type override for random-assignment weighting.
-
Field Details
-
skilltreeName
This skilltree's unique name, as the file that defines it is called. -
inheritedSkilltreeName
Name of the skilltree this one inherits upgrades from, ornullwhen it stands alone. -
description
Lore lines shown in the selection menu. -
icon
Icon shown in the selection menu, ornullfor the default. -
displayName
Name shown to players, ornullto usegetName(). -
maxLevel
protected int maxLevelHighest level this skilltree grants upgrades for;0means unbounded. -
requiredLevel
protected int requiredLevelLevel a pet must reach before it may select this skilltree. -
order
protected int orderSort position in the selection menu; lower comes first. -
weight
protected double weightRelative chance of being picked when skilltrees are assigned at random. -
weightOverrides
Per-pet-type overrides ofweight. -
mobTypes
Pet types allowed to use this skilltree; empty means all of them. -
upgrades
Level-gated upgrades, ordered by rule priority. -
notifications
Level-gated messages shown to the owner. -
requirementSettings
Requirement blocks gating who may select this skilltree.
-
-
Constructor Details
-
Skilltree
Creates a new skilltree with the given internal name.- Parameters:
name- the unique identifier for this skilltree
-
-
Method Details
-
setWeight
public void setWeight(double weight) Default weight used by random assignment when no per-type override exists.- Parameters:
weight- the relative chance of being picked at random
-
setWeightOverride
Per-type override for random-assignment weighting.- Parameters:
type- the pet type to override forweight- the relative chance for that type
-
getWeight
Random-assignment weight for the given pet type.- Parameters:
type- the pet type to read- Returns:
- the override for that type, or the shared weight when none is set
-
getName
Returns the unique internal name of this skilltree.- Returns:
- this skilltree's unique name
-
getDescription
Returns an unmodifiable view of this skilltree's description lines.- Returns:
- the lore lines shown in the selection menu
-
addDescriptionLine
Appends a single line to the description.- Parameters:
line- the lore line to append
-
addDescription
Appends multiple lines to the description.- Parameters:
lines- the lore lines to append
-
removeDescriptionLine
public void removeDescriptionLine(int index) Removes the description line at the specified index.- Parameters:
index- position of the line to remove
-
clearDescription
public void clearDescription()Removes all description lines. -
getIcon
Returns the icon for this skilltree, creating a default one if not yet set.- Returns:
- the menu icon, or
nullfor the default
-
getMaxLevel
public int getMaxLevel()Returns the maximum level for this skilltree.If not explicitly set (or set to 0), falls back to the global level cap from configuration.
- Returns:
- the highest level this skilltree grants upgrades for
-
setMaxLevel
public void setMaxLevel(int maxLevel) Sets the maximum level for this skilltree, clamped to the global level cap. A value of 0 or below means "use the global cap".- Parameters:
maxLevel- highest level to grant upgrades for;0for unbounded
-
setRequiredLevel
public void setRequiredLevel(int requiredLevel) Sets the minimum pet level required before this skilltree becomes available. Clamped to a minimum of 1.- Parameters:
requiredLevel- level a pet must reach to select this skilltree
-
getDisplayName
Returns the display name shown to players, falling back to the internal name if unset.- Returns:
- the name shown to players
-
hasDisplayName
public boolean hasDisplayName()Returnstrueif a custom display name has been explicitly set.- Returns:
trueif an explicit display name is set
-
hasInheritance
public boolean hasInheritance()Returnstrueif this skilltree inherits from another registered skilltree.- Returns:
trueif this skilltree inherits from another
-
getUpgrades
Collects all upgrades that should be applied at the given level, including inherited ones.Inherited skilltree upgrades are resolved first (depth-first), then this tree's own upgrades are appended. Circular inheritance is detected and prevented.
- Parameters:
level- the pet's current level- Returns:
- an ordered list of upgrades to apply
-
getUpgrades
Internal recursive method that collects upgrades while tracking already-visited trees to avoid circular inheritance loops.- Parameters:
level- the pet level to collect upgrades forcomputedSkilltrees- names already visited, guarding against an inheritance cycle- Returns:
- every upgrade active at that level, inherited ones included
-
addUpgrade
Registers an upgrade to be applied whenever the given level rule matches. The backing list is kept sorted by rule priority (stable) so the getters can iterate it directly.- Parameters:
levelRule- the rule determining at which levels this upgrade activatesupgrade- the upgrade to apply
-
getNotifications
Collects all notification messages that should be displayed at the given level.- Parameters:
level- the pet's current level- Returns:
- the list of notification strings whose rules match this level
-
addNotification
Registers a notification message to be displayed when the given level rule matches. The backing list is kept sorted by rule priority (stable), likeaddUpgrade(de.Keyle.MyPet.api.skill.skilltree.levelrule.LevelRule, de.Keyle.MyPet.api.skill.Upgrade<?>).- Parameters:
levelRule- the rule determining at which levels the notification firesnotification- the message to display to the pet owner
-
setMobTypes
Replaces the set of pet types that are allowed to use this skilltree.- Parameters:
mobTypes- the collection of allowed pet types
-
addRequirementSettings
Adds a requirement configuration block that will be evaluated by the namedRequirement.- Parameters:
settings- the requirement name and its parameters
-
checkRequirements
Evaluates all configured requirements against the given pet.Returns
trueonly if every requirement passes. Short-circuits on the first failure.- Parameters:
pet- the pet to check requirements against- Returns:
trueif the pet satisfies all requirements for this skilltree
-
getFailedRequirements
Names of the requirements the pet currently fails, in evaluation order.- Parameters:
pet- the pet to test- Returns:
- names of the requirements that pet does not meet; empty when it may select this skilltree
-
isAscensionFor
True if this tree's Skilltree requirement names the pet's current tree — i.e. selecting it is an ascension.- Parameters:
pet- the pet to test- Returns:
trueif this skilltree is an ascension from the pet's current one
-
getInheritedSkilltreeName
Name of the skilltree this one inherits upgrades from, ornullwhen it stands alone.- Returns:
- the inherited skilltree's name, or
nullwhen it stands alone
-
setInheritedSkilltreeName
Name of the skilltree this one inherits upgrades from, ornullwhen it stands alone.- Parameters:
inheritedSkilltreeName- the inherited skilltree's name, ornull
-
setIcon
Icon shown in the selection menu, ornullfor the default.- Parameters:
icon- the menu icon
-
setDisplayName
Name shown to players, ornullto usegetName().- Parameters:
displayName- the name to show players
-
getRequiredLevel
public int getRequiredLevel()Level a pet must reach before it may select this skilltree.- Returns:
- the level a pet must reach before selecting this skilltree
-
setOrder
public void setOrder(int order) Sort position in the selection menu; lower comes first.- Parameters:
order- the sort position; lower comes first
-
getOrder
public int getOrder()Sort position in the selection menu; lower comes first.- Returns:
- the sort position in the selection menu
-
getMobTypes
Pet types allowed to use this skilltree; empty means all of them.- Returns:
- the pet types allowed to use this skilltree; empty means all of them
-
getRequirementSettings
Requirement blocks gating who may select this skilltree.- Returns:
- the requirement blocks gating selection
-