java.lang.Object
studio.magemonkey.fabled.api.skills.Skill
All Implemented Interfaces:
IconHolder
Direct Known Subclasses:
DynamicSkill

public abstract class Skill extends Object implements IconHolder
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
    Modifier and Type
    Field
    Description
    protected final 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 Summary

    Constructors
    Constructor
    Description
    Skill(String name, String type, org.bukkit.inventory.ItemStack indicator, int maxLevel)
    Initializes 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.
    Skill(String name, String type, org.bukkit.Material indicator, int maxLevel)
    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 Type
    Method
    Description
    boolean
    canAutoLevel(int level)
    Checks whether the skill can automatically level up to the next stage.
    boolean
    Checks whether this skill can be cast by players
    boolean
     
    void
    Clears the set combo for the skill.
    boolean
    Checks whether a message is sent when attempting to run the skill while in cooldown
    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
    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
    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
    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
    protected String
    format(double value)
    Formats a double value to prevent excessive decimals
    protected Object
    getAttr(org.bukkit.entity.LivingEntity caster, String key, int level)
    Retrieves an attribute value for using in the icon lore
    protected String
    Formats an attribute name for applying to the indicator
    int
    Retrieves the ID of the skill's combo
    double
    getCooldown(int level)
    Retrieves the cooldown of the skill in seconds
    int
    getCost(int level)
    Retrieves the skill point cost of the skill
    Retrieves the skill's description
    org.bukkit.inventory.ItemStack
    Fetches the icon for the skill for the player
    org.bukkit.inventory.ItemStack
    Retrieves the indicator representing the skill for menus
    org.bukkit.inventory.ItemStack
    getIndicator(PlayerSkill skillData, boolean brief)
    Retrieves the indicator for the skill while applying filters to match the player-specific data.
    Retrieves the configuration key for the skill
    int
    getLevelReq(int level)
    Retrieves the level requirement for the skill to reach the next level
    double
    getManaCost(int level)
    Retrieves the mana cost of the skill
    int
    Retrieves the max level the skill can reach
    Retrieves the message for the skill to display when cast.
    Retrieves the name of the skill
    double
    getRange(int level)
    Retrieves the range of the skill in blocks
    Retrieves the settings for the skill in a read-only format
    Retrieves the skill required to be upgraded before this one
    int
    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 tools
    Retrieves the descriptive type of the skill
    boolean
    Checks whether the skill has been assigned a click combination.
    boolean
     
    boolean
     
    boolean
     
    boolean
    Checks whether the skill has a message to display when cast.
    boolean
    Checks whether the skill requires another before leveling up
    boolean
    isAllowed(org.bukkit.entity.Player player)
     
    boolean
     
    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 configuration
    boolean
    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 data
    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.
    void
    setCombo(int combo)
    Sets the click combo for the skill
    void
    softSave(studio.magemonkey.codex.mccore.config.parse.DataSection config)
    Saves some skill data to the config, avoiding overwriting any pre-existing data
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • settings

      protected final Settings 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

      public Skill(String name, String type, org.bukkit.Material indicator, int maxLevel)
      Initializes a new skill that doesn't require any other skill.
      Parameters:
      name - name of the skill
      type - descriptive type of the skill
      indicator - indicator to represent the skill
      maxLevel - 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 skill
      type - descriptive type of the skill
      indicator - indicator to represent the skill
      maxLevel - max level the skill can reach
      skillReq - name of the skill required to raise this one
      skillReqLevel - level of the required skill needed
    • Skill

      public Skill(String name, String type, org.bukkit.inventory.ItemStack indicator, int maxLevel)
      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 skill
      type - descriptive type of the skill
      indicator - indicator to respresent the skill
      maxLevel - 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 skill
      type - descriptive type of the skill
      indicator - indicator to represent the skill
      maxLevel - max level the skill can reach
      skillReq - name of the skill required to raise this one
      skillReqLevel - 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 skill
      type - descriptive type of the skill
      indicator - indicator to represent the skill
      maxLevel - max level the skill can reach
      skillReq - name of the skill required to raise this one
      skillReqLevel - level of the required skill needed
      attributes - 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

      public List<String> 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

      public ReadOnlySettings 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

      public org.bukkit.inventory.ItemStack getIcon(PlayerData data)
      Fetches the icon for the skill for the player
      Specified by:
      getIcon in interface IconHolder
      Parameters:
      data - player to get for
      Returns:
      the skill icon
    • isAllowed

      public boolean isAllowed(org.bukkit.entity.Player player)
      Specified by:
      isAllowed in interface IconHolder
    • hasDependency

      public boolean hasDependency(PlayerData playerData)
    • isCompatible

      public boolean isCompatible(PlayerData playerData)
    • hasInvestedEnough

      public boolean hasInvestedEnough(PlayerData playerData)
    • hasEnoughAttributes

      public boolean hasEnoughAttributes(PlayerData playerData)
    • checkSingleAttribute

      public boolean checkSingleAttribute(PlayerData playerData, String key)
    • getIndicator

      public org.bukkit.inventory.ItemStack getIndicator(PlayerSkill skillData, boolean brief)
      Retrieves the indicator for the skill while applying filters to match the player-specific data.
      Parameters:
      skillData - player data
      Returns:
      filtered skill indicator
    • getAttrName

      protected String getAttrName(String key)
      Formats an attribute name for applying to the indicator
      Parameters:
      key - attribute key
      Returns:
      formatted attribute name
    • getAttr

      protected Object getAttr(org.bukkit.entity.LivingEntity caster, String key, int level)
      Retrieves an attribute value for using in the icon lore
      Parameters:
      caster - owner of the skill
      key - attribute key
      level - skill level
      Returns:
      attribute value
    • format

      protected String format(double value)
      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 from
      radius - 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 damage
      damage - amount of damage to deal
      source - 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 damage
      damage - amount of damage to deal
      source - 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 damage
      damage - amount of damage to deal
      source - source of the damage (skill caster)
      classification - type of damage to deal
      knockback - whether the damage should apply knockback
      ignoreDivinity - 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 damage
      damage - amount of damage to deal
      source - source of the damage (skill caster)
      classification - type of damage to deal
      knockback - whether the damage should apply knockback
      ignoreDivinity - whether the skill's damage should use divinity's overrides
      cause - 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 damage
      damage - amount of damage to deal
      source - source of the damage (skill caster)
    • playPreview

      public void playPreview(PlayerData playerData, int level)
      Starts the skill's preview effects. Removal of any registered listeners, tasks, entities, or other temporary effects should be included in a Runnable passed to PlayerData.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

      public String 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

      public String getName()
      Retrieves the name of the skill
      Returns:
      skill name
    • getType

      public String getType()
      Retrieves the descriptive type of the skill
      Returns:
      descriptive type of the skill
    • getMessage

      public String getMessage()
      Retrieves the message for the skill to display when cast.
      Returns:
      cast message of the skill
    • getSkillReq

      public String 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