Class PlayerClass
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
ConstructorsConstructorDescriptionPlayerClass
(PlayerData player, FabledClass classData) Initializes a new PlayerClass. -
Method Summary
Modifier and TypeMethodDescriptiongetData()
Retrieves the generic data for the class.int
Whenis enabled
gets the amount of skill points this class has earned.double
getExp()
Retrieves the experience of the class towards the next level.double
Retrieves the amount of health this class provides the playerint
getLevel()
Retrieves the current level of the class.double
getMana()
Retrieves the amount of mana this class provides the playerRetrieves 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
Gives experience to the class under the context of the experience source.void
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 aPlayerExperienceLostEvent
event before taking the experience.void
loseExp
(double amount, boolean percent, boolean changeLevel, boolean showMessage) Causes the player to lose experience This will launch aPlayerExperienceLostEvent
event before taking the experience.void
loseLevels
(int amount) void
setClassData
(FabledClass classData) Sets the class data this player class is based off of, optionally resetting the class progress.void
setEarnedPoints
(int amount) Whenis enabled
sets the amount of skill points this class has earned.void
setExp
(double exp) Sets the current experience for the playervoid
setLevel
(int level) Sets the level for the classvoid
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.
-
Constructor Details
-
PlayerClass
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 dataclassData
- class template
-
-
Method Details
-
getPlayerData
Retrieves the data of the player owning this class.
- Returns:
- data of owning player
-
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) Whenis 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()Whenis 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
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 givesource
- 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
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 givesource
- type of the source of the experience
-
giveExp
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 givesource
- type of the source of the experienceshowMessage
- 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 aPlayerExperienceLostEvent
event before taking the experience.- Parameters:
amount
- percent of experience to losepercent
- whether to take the amount as a percentagechangeLevel
- whether to lower the level if the exp lost exceeds the current exp, or to cap at 0 exp and keep the current levelshowMessage
- whether to display the loss message
-
loseExp
public void loseExp(double percent) Causes the player to lose experience This will launch aPlayerExperienceLostEvent
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
Sets the class data this player class is based off of, optionally resetting the class progress.- Parameters:
classData
- class data to switch to
-