Class Skill
java.lang.Object
studio.magemonkey.fabled.api.skills.Skill
- All Implemented Interfaces:
IconHolder
- Direct Known Subclasses:
DynamicSkill
Represents a template for a skill used in the RPG system. This is
the class to extend when creating your own custom skills.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new skill that doesn't require any other skill.Skill
(String name, String type, org.bukkit.inventory.ItemStack indicator, int maxLevel, String skillReq, int skillReqLevel) Initializes a skill that requires another skill to be upgraded before it can be upgraded itself.Skill
(String name, String type, org.bukkit.inventory.ItemStack indicator, int maxLevel, String skillReq, int skillReqLevel, Map<String, Map.Entry<Double, Double>> attributes) Initializes a skill that requires another skill to be upgraded before it can be upgraded itself and enough attributes.Initializes a new skill that doesn't require any other skill.Skill
(String name, String type, org.bukkit.Material indicator, int maxLevel, String skillReq, int skillReqLevel) Initializes a skill that requires another skill to be upgraded before it can be upgraded itself. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canAutoLevel
(int level) Checks whether the skill can automatically level up to the next stage.boolean
canCast()
Checks whether this skill can be cast by playersboolean
checkSingleAttribute
(PlayerData playerData, String key) void
Clears the set combo for the skill.boolean
Checks whether a message is sent when attempting to run the skill while in cooldownvoid
damage
(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source) Applies skill damage to the target, launching the skill damage eventvoid
damage
(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source, String classification) Applies skill damage to the target, launching the skill damage eventvoid
damage
(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source, String classification, boolean knockback, boolean ignoreDivinity) Applies skill damage to the target, launching the skill damage eventvoid
damage
(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source, String classification, boolean knockback, boolean ignoreDivinity, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Applies skill damage to the target, launching the skill damage eventprotected String
format
(double value) Formats a double value to prevent excessive decimalsprotected Object
Retrieves an attribute value for using in the icon loreprotected String
getAttrName
(String key) Formats an attribute name for applying to the indicatorint
getCombo()
Retrieves the ID of the skill's combodouble
getCooldown
(int level) Retrieves the cooldown of the skill in secondsint
getCost
(int level) Retrieves the skill point cost of the skillRetrieves the skill's descriptionorg.bukkit.inventory.ItemStack
getIcon
(PlayerData data) Fetches the icon for the skill for the playerorg.bukkit.inventory.ItemStack
Retrieves the indicator representing the skill for menusorg.bukkit.inventory.ItemStack
getIndicator
(PlayerSkill skillData, boolean brief) Retrieves the indicator for the skill while applying filters to match the player-specific data.getKey()
Retrieves the configuration key for the skillint
getLevelReq
(int level) Retrieves the level requirement for the skill to reach the next leveldouble
getManaCost
(int level) Retrieves the mana cost of the skillint
Retrieves the max level the skill can reachRetrieves the message for the skill to display when cast.getName()
Retrieves the name of the skilldouble
getRange
(int level) Retrieves the range of the skill in blocksRetrieves the settings for the skill in a read-only formatRetrieves the skill required to be upgraded before this oneint
Retrieves the level of the required skill needed to be obtained before this one can be upgraded.org.bukkit.inventory.ItemStack
Gets the indicator for the skill for the GUI toolsgetType()
Retrieves the descriptive type of the skillboolean
hasCombo()
Checks whether the skill has been assigned a click combination.boolean
hasDependency
(PlayerData playerData) boolean
hasEnoughAttributes
(PlayerData playerData) boolean
hasInvestedEnough
(PlayerData playerData) boolean
Checks whether the skill has a message to display when cast.boolean
Checks whether the skill requires another before leveling upboolean
isAllowed
(org.bukkit.entity.Player player) boolean
isCompatible
(PlayerData playerData) static boolean
Checks whether the current damage event is due to skills damaging an entity.void
load
(studio.magemonkey.codex.mccore.config.parse.DataSection config) Loads skill data from the configurationboolean
Checks whether the skill needs a permission for a player to use it.void
playPreview
(PlayerData playerData, int level) Starts the skill's preview effects.void
save
(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves the skill data to the configuration, overwriting all previous datavoid
sendMessage
(org.bukkit.entity.Player player, double radius) Sends the skill message if one is present from the player to entities within the given radius.void
setCombo
(int combo) Sets the click combo for the skillvoid
softSave
(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves some skill data to the config, avoiding overwriting any pre-existing datavoid
trueDamage
(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source) Applies skill damage to the target, launching the skill damage event and keeping the damage version compatible.
-
Field Details
-
settings
The settings for the skill which include configurable stats for your mechanics and the defaults such as mana cost, level requirement, skill point cost, and cooldown.
-
-
Constructor Details
-
Skill
Initializes a new skill that doesn't require any other skill.- Parameters:
name
- name of the skilltype
- descriptive type of the skillindicator
- indicator to represent the skillmaxLevel
- max level the skill can reach
-
Skill
public Skill(String name, String type, org.bukkit.Material indicator, int maxLevel, String skillReq, int skillReqLevel) Initializes a skill that requires another skill to be upgraded before it can be upgraded itself.- Parameters:
name
- name of the skilltype
- descriptive type of the skillindicator
- indicator to represent the skillmaxLevel
- max level the skill can reachskillReq
- name of the skill required to raise this oneskillReqLevel
- level of the required skill needed
-
Skill
Initializes a new skill that doesn't require any other skill. The indicator's display name and lore will be used as the layout for the skill tree display.- Parameters:
name
- name of the skilltype
- descriptive type of the skillindicator
- indicator to respresent the skillmaxLevel
- max level the skill can reach
-
Skill
public Skill(String name, String type, org.bukkit.inventory.ItemStack indicator, int maxLevel, String skillReq, int skillReqLevel) Initializes a skill that requires another skill to be upgraded before it can be upgraded itself. The indicator's display name and lore will be used as the layout for the skill tree display.- Parameters:
name
- name of the skilltype
- descriptive type of the skillindicator
- indicator to represent the skillmaxLevel
- max level the skill can reachskillReq
- name of the skill required to raise this oneskillReqLevel
- level of the required skill needed
-
Skill
public Skill(String name, String type, org.bukkit.inventory.ItemStack indicator, int maxLevel, String skillReq, int skillReqLevel, Map<String, Map.Entry<Double, Double>> attributes) Initializes a skill that requires another skill to be upgraded before it can be upgraded itself and enough attributes. The indicator's display name and lore will be used as the layout for the skill tree display.- Parameters:
name
- name of the skilltype
- descriptive type of the skillindicator
- indicator to represent the skillmaxLevel
- max level the skill can reachskillReq
- name of the skill required to raise this oneskillReqLevel
- level of the required skill neededattributes
- attributes and their levels required to upgrade skill
-
-
Method Details
-
hasCombo
public boolean hasCombo()Checks whether the skill has been assigned a click combination.- Returns:
- true if has a combo, false otherwise
-
canAutoLevel
public boolean canAutoLevel(int level) Checks whether the skill can automatically level up to the next stage.- Parameters:
level
- - the current level of the skill- Returns:
- true if skill can level up automatically to the next level, false otherwise
-
hasMessage
public boolean hasMessage()Checks whether the skill has a message to display when cast.- Returns:
- true if has a message, false otherwise
-
clearCombo
public void clearCombo()Clears the set combo for the skill. Only the API should call this. -
needsPermission
public boolean needsPermission()Checks whether the skill needs a permission for a player to use it.- Returns:
- true if the skill requires a permission to use
-
hasSkillReq
public boolean hasSkillReq()Checks whether the skill requires another before leveling up- Returns:
- true if the skill requires another skill, false otherwise
-
getDescription
Retrieves the skill's description- Returns:
- description of the skill
-
getLevelReq
public int getLevelReq(int level) Retrieves the level requirement for the skill to reach the next level- Parameters:
level
- current level of the skill- Returns:
- level requirement for the next level
-
getManaCost
public double getManaCost(int level) Retrieves the mana cost of the skill- Parameters:
level
- current level of the skill- Returns:
- mana cost
-
getCooldown
public double getCooldown(int level) Retrieves the cooldown of the skill in seconds- Parameters:
level
- current level of the skill- Returns:
- cooldown
-
cooldownMessage
public boolean cooldownMessage()Checks whether a message is sent when attempting to run the skill while in cooldown- Returns:
- true if the message is sent, false otherwise
-
getRange
public double getRange(int level) Retrieves the range of the skill in blocks- Parameters:
level
- current level of the skill- Returns:
- target range
-
getCost
public int getCost(int level) Retrieves the skill point cost of the skill- Parameters:
level
- current level of the skill- Returns:
- skill point cost
-
getSettings
Retrieves the settings for the skill in a read-only format- Returns:
- settings for the skill in a read-only format
-
canCast
public boolean canCast()Checks whether this skill can be cast by players- Returns:
- true if can be cast, false otherwise
-
getToolIndicator
public org.bukkit.inventory.ItemStack getToolIndicator()Gets the indicator for the skill for the GUI tools- Returns:
- GUI tool indicator
-
getIcon
Fetches the icon for the skill for the player- Specified by:
getIcon
in interfaceIconHolder
- Parameters:
data
- player to get for- Returns:
- the skill icon
-
isAllowed
public boolean isAllowed(org.bukkit.entity.Player player) - Specified by:
isAllowed
in interfaceIconHolder
-
hasDependency
-
isCompatible
-
hasInvestedEnough
-
hasEnoughAttributes
-
checkSingleAttribute
-
getIndicator
Retrieves the indicator for the skill while applying filters to match the player-specific data.- Parameters:
skillData
- player data- Returns:
- filtered skill indicator
-
getAttrName
Formats an attribute name for applying to the indicator- Parameters:
key
- attribute key- Returns:
- formatted attribute name
-
getAttr
Retrieves an attribute value for using in the icon lore- Parameters:
caster
- owner of the skillkey
- attribute keylevel
- skill level- Returns:
- attribute value
-
format
Formats a double value to prevent excessive decimals- Parameters:
value
- double value to format- Returns:
- formatted double value
-
sendMessage
public void sendMessage(org.bukkit.entity.Player player, double radius) Sends the skill message if one is present from the player to entities within the given radius.- Parameters:
player
- player to project the message fromradius
- radius to include targets of the message
-
damage
public void damage(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source) Applies skill damage to the target, launching the skill damage event- Parameters:
target
- target to receive the damagedamage
- amount of damage to dealsource
- source of the damage (skill caster)
-
damage
public void damage(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source, String classification) Applies skill damage to the target, launching the skill damage event- Parameters:
target
- target to receive the damagedamage
- amount of damage to dealsource
- source of the damage (skill caster)classification
- type of damage to deal
-
damage
public void damage(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source, String classification, boolean knockback, boolean ignoreDivinity) Applies skill damage to the target, launching the skill damage event- Parameters:
target
- target to receive the damagedamage
- amount of damage to dealsource
- source of the damage (skill caster)classification
- type of damage to dealknockback
- whether the damage should apply knockbackignoreDivinity
- whether the skill's damage should use divinity's overrides
-
damage
public void damage(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source, String classification, boolean knockback, boolean ignoreDivinity, org.bukkit.event.entity.EntityDamageEvent.DamageCause cause) Applies skill damage to the target, launching the skill damage event- Parameters:
target
- target to receive the damagedamage
- amount of damage to dealsource
- source of the damage (skill caster)classification
- type of damage to dealknockback
- whether the damage should apply knockbackignoreDivinity
- whether the skill's damage should use divinity's overridescause
- the cause of the damage, might affect death messages
-
trueDamage
public void trueDamage(org.bukkit.entity.LivingEntity target, double damage, org.bukkit.entity.LivingEntity source) Applies skill damage to the target, launching the skill damage event and keeping the damage version compatible.- Parameters:
target
- target to receive the damagedamage
- amount of damage to dealsource
- source of the damage (skill caster)
-
playPreview
Starts the skill's preview effects. Removal of any registered listeners, tasks, entities, or other temporary effects should be included in aRunnable
passed toPlayerData.setOnPreviewStop(Runnable)
-
save
public void save(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves the skill data to the configuration, overwriting all previous data- Parameters:
config
- config to save to
-
softSave
public void softSave(studio.magemonkey.codex.mccore.config.parse.DataSection config) Saves some skill data to the config, avoiding overwriting any pre-existing data- Parameters:
config
- config to save to
-
load
public void load(studio.magemonkey.codex.mccore.config.parse.DataSection config) Loads skill data from the configuration- Parameters:
config
- config to load from
-
isSkillDamage
public static boolean isSkillDamage()Checks whether the current damage event is due to skills damaging an entity. This method is used by the API and shouldn't be used by other plugins.- Returns:
- true if caused by a skill, false otherwise
-
getKey
Retrieves the configuration key for the skill- Returns:
- configuration key for the skill
-
getIndicator
public org.bukkit.inventory.ItemStack getIndicator()Retrieves the indicator representing the skill for menus- Returns:
- indicator for the skill
-
getName
Retrieves the name of the skill- Returns:
- skill name
-
getType
Retrieves the descriptive type of the skill- Returns:
- descriptive type of the skill
-
getMessage
Retrieves the message for the skill to display when cast.- Returns:
- cast message of the skill
-
getSkillReq
Retrieves the skill required to be upgraded before this one- Returns:
- required skill
-
getMaxLevel
public int getMaxLevel()Retrieves the max level the skill can reach- Returns:
- max skill level
-
getSkillReqLevel
public int getSkillReqLevel()Retrieves the level of the required skill needed to be obtained before this one can be upgraded.- Returns:
- required skill level
-
setCombo
public void setCombo(int combo) Sets the click combo for the skill- Parameters:
combo
- new combo
-
getCombo
public int getCombo()Retrieves the ID of the skill's combo- Returns:
- combo ID
-