Class PlayerClass

java.lang.Object
studio.magemonkey.fabled.api.player.PlayerClass

public class PlayerClass extends Object

Represents a player's class progress.

This class if for handling individual players.

This does not include information about the class specifically, rather what the player has within the class. For more general information about the class, you should use the RPGClass class.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PlayerClass(PlayerData player, FabledClass classData)
    Initializes a new PlayerClass.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the generic data for the class.
    int
    When is enabled gets the amount of skill points this class has earned.
    double
    Retrieves the experience of the class towards the next level.
    double
    Retrieves the amount of health this class provides the player
    int
    Retrieves the current level of the class.
    double
    Retrieves the amount of mana this class provides the player
    Retrieves the data of the player owning this class.
    int
    Retrieves the number of skill points the class has currently available.
    int
    Retrieves the required experience to level up to the next level.
    double
    Retrieves the total amount of experience the player has accumulated for this class since professing as it.
    void
    giveExp(double amount, ExpSource source)
    Gives experience to the class under the context of the experience source.
    void
    giveExp(double amount, ExpSource source, boolean showMessage)
    Gives experience to the class under the context of the experience source.
    void
    giveLevels(int amount)
    Gives levels to the player's class, leveling it up.
    void
    givePoints(int amount)
    Gives skill points to be used for the class.
    void
    givePoints(int amount, PointSource source)
    Gives skill points to be used for the class.
    boolean
    Checks whether the class has reached the max level.
    void
    loseExp(double percent)
    Causes the player to lose experience This will launch a PlayerExperienceLostEvent event before taking the experience.
    void
    loseExp(double amount, boolean percent, boolean changeLevel, boolean showMessage)
    Causes the player to lose experience This will launch a PlayerExperienceLostEvent event before taking the experience.
    void
    loseLevels(int amount)
     
    void
    Sets the class data this player class is based off of, optionally resetting the class progress.
    void
    setEarnedPoints(int amount)
    When is enabled sets the amount of skill points this class has earned.
    void
    setExp(double exp)
    Sets the current experience for the player
    void
    setLevel(int level)
    Sets the level for the class
    void
    setPoints(int amount)
    Sets the amount of points the player's class has without launching an event.
    void
    usePoints(int amount)
    Uses points from the player for skill upgrades.

    Methods inherited from class java.lang.Object

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

    • PlayerClass

      public PlayerClass(PlayerData player, FabledClass classData)
      Initializes a new PlayerClass. This should not be used by other plugins as the API provides the data. Get instances from the PlayerData object.
      Parameters:
      player - owning player data
      classData - class template
  • Method Details

    • getPlayerData

      public PlayerData getPlayerData()

      Retrieves the data of the player owning this class.

      Returns:
      data of owning player
    • getData

      public FabledClass getData()

      Retrieves the generic data for the class.

      Returns:
      generic data for the class
    • getExp

      public double getExp()

      Retrieves the experience of the class towards the next level.

      This should not ever be higher than the required experience.

      Returns:
      the current experience of the class towards the next level
    • setExp

      public void setExp(double exp)
      Sets the current experience for the player
      Parameters:
      exp - experience to set to
    • getRequiredExp

      public int getRequiredExp()

      Retrieves the required experience to level up to the next level.

      Returns:
      the current required experience
    • getTotalExp

      public double getTotalExp()

      Retrieves the total amount of experience the player has accumulated for this class since professing as it.

      Returns:
      total accumulated experience for the class
    • getLevel

      public int getLevel()

      Retrieves the current level of the class.

      This should never be less than 1 or greater than the maximum level.

      Returns:
      current level of the class
    • setLevel

      public void setLevel(int level)
      Sets the level for the class
      Parameters:
      level - level to set to
    • getPoints

      public int getPoints()

      Retrieves the number of skill points the class has currently available.

      This should never be a negative number.

      Returns:
      number of available skill points
    • setPoints

      public void setPoints(int amount)

      Sets the amount of points the player's class has without launching an event.

      This cannot be less than 0.

      This is used primarily for initialization. You should generally use givePoints(int, PointSource) instead.

      Parameters:
      amount - number of points to set it to
    • setEarnedPoints

      public void setEarnedPoints(int amount)
      When is enabled sets the amount of skill points this class has earned. Used if the shared skill points option is later disabled, to correctly redistribute the points across all classes
    • getEarnedPoints

      public int getEarnedPoints()
      When is enabled gets the amount of skill points this class has earned. Used if the shared skill points option is later disabled, to correctly redistribute the points across all classes
    • isLevelMaxed

      public boolean isLevelMaxed()

      Checks whether the class has reached the max level.

      Returns:
      true if max level, false otherwise
    • getHealth

      public double getHealth()
      Retrieves the amount of health this class provides the player
      Returns:
      health provided for the player by this class
    • getMana

      public double getMana()
      Retrieves the amount of mana this class provides the player
      Returns:
      mana provided for the player by this class
    • givePoints

      public void givePoints(int amount)

      Gives skill points to be used for the class.

      The number of points cannot be negative.

      This calls an event that can be cancelled or have the number of points modified.

      This treats the points as coming from the source "SPECIAL".

      Parameters:
      amount - amount of points to give
      Throws:
      IllegalArgumentException - if the points are less than 1
    • givePoints

      public void givePoints(int amount, PointSource source)

      Gives skill points to be used for the class.

      The number of points cannot be negative.

      This calls an event that can be cancelled or have the number of points modified.

      Parameters:
      amount - amount of points to give
      source - source of the points
      Throws:
      IllegalArgumentException - if the points are less than 1
    • usePoints

      public void usePoints(int amount)
      Uses points from the player for skill upgrades.
      Parameters:
      amount - amount of points to use
    • giveExp

      public void giveExp(double amount, ExpSource source)

      Gives experience to the class under the context of the experience source.

      This will also check for leveling up after the experience is added.

      If the class does not normally receive experience from the source, it will still launch an experience event, just it will start off as cancelled in case it should still be given in select circumstances.

      Parameters:
      amount - amount of experience to give
      source - type of the source of the experience
    • giveExp

      public void giveExp(double amount, ExpSource source, boolean showMessage)

      Gives experience to the class under the context of the experience source.

      This will also check for leveling up after the experience is added.

      If the class does not normally receive experience from the source, or the player is already max level, it will still launch an experience event, just it will start off as cancelled in case it should still be given in select circumstances.

      Parameters:
      amount - amount of experience to give
      source - type of the source of the experience
      showMessage - whether to show the configured message if enabled
    • loseExp

      public void loseExp(double amount, boolean percent, boolean changeLevel, boolean showMessage)
      Causes the player to lose experience This will launch a PlayerExperienceLostEvent event before taking the experience.
      Parameters:
      amount - percent of experience to lose
      percent - whether to take the amount as a percentage
      changeLevel - whether to lower the level if the exp lost exceeds the current exp, or to cap at 0 exp and keep the current level
      showMessage - whether to display the loss message
    • loseExp

      public void loseExp(double percent)
      Causes the player to lose experience This will launch a PlayerExperienceLostEvent event before taking the experience.
      Parameters:
      percent - percent of experience to lose
    • giveLevels

      public void giveLevels(int amount)

      Gives levels to the player's class, leveling it up.

      The amount of levels must be a positive number.

      This will launch a level event for the gained levels.

      Parameters:
      amount - amount of levels to give
      Throws:
      IllegalArgumentException - when the level amount is less than 1
    • loseLevels

      public void loseLevels(int amount)
    • setClassData

      public void setClassData(FabledClass classData)
      Sets the class data this player class is based off of, optionally resetting the class progress.
      Parameters:
      classData - class data to switch to