Package ru.cwcode.cwutils.xp
Class XpUtils
java.lang.Object
ru.cwcode.cwutils.xp.XpUtils
A utility for managing Player experience properly.
- Author:
- Jikoo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidchangeExp(org.bukkit.entity.Player player, int exp) Change a Player's exp.static voiddropExp(org.bukkit.Location location, int xp) static intgetExp(org.bukkit.entity.Player player) Calculates a player's total exp based on level and progress to next.static intgetExpFromLevel(int level) Calculates total experience based on level.static doublegetLevelFromExp(long exp) Calculates level based on total experience.
-
Constructor Details
-
XpUtils
public XpUtils()
-
-
Method Details
-
dropExp
public static void dropExp(org.bukkit.Location location, int xp) -
getExp
public static int getExp(org.bukkit.entity.Player player) Calculates a player's total exp based on level and progress to next.- Parameters:
player- the Player- Returns:
- the amount of exp the Player has
- See Also:
-
getExpFromLevel
public static int getExpFromLevel(int level) Calculates total experience based on level.- Parameters:
level- the level- Returns:
- the total experience calculated
- See Also:
-
- ref
"One can determine how much experience has been collected to reach a level using the equations:
Total Experience = [Level]2 + 6[Level] (at levels 0-15) 2.5[Level]2 - 40.5[Level] + 360 (at levels 16-30) 4.5[Level]2 - 162.5[Level] + 2220 (at level 31+)"
- ref
-
getLevelFromExp
public static double getLevelFromExp(long exp) Calculates level based on total experience.- Parameters:
exp- the total experience- Returns:
- the level calculated
-
changeExp
public static void changeExp(org.bukkit.entity.Player player, int exp) Change a Player's exp.This method should be used in place of
Player.giveExp(int), which does not properly account for different levels requiring different amounts of experience.- Parameters:
player- the Player affectedexp- the amount of experience to add or remove
-