Package dev.satyrn.xpeconomy.utils
Class PlayerXPUtils
java.lang.Object
dev.satyrn.xpeconomy.utils.PlayerXPUtils
Performs XP conversion, calculation, and updating.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigInteger
getCurrentLevelProgress
(BigInteger level, BigDecimal percent) Gets the current XP amount for the player's current progress towards leveling.static BigInteger
getPlayerXPTotal
(@NotNull org.bukkit.entity.Player player) Gets the total amount of XP a player has.static BigInteger
getPlayerXPTotal
(UUID uuid) Gets the total amount of XP a player has.static BigInteger
getTotalXPValue
(int level, float progress) Gets the total amount of XP a player with the given level and level-up progress has.static BigInteger
getXPForLevel
(BigInteger level) Calculates the total XP value for a given level.static void
setPlayerXPTotal
(@NotNull UUID uuid, @NotNull BigInteger total) Sets a player's experience values to a specific balance.static void
setPlayerXPTotal
(@NotNull org.bukkit.entity.Player player, @NotNull BigInteger total) Sets a player's experience values to a specific total.static org.javatuples.Pair<BigInteger,
BigDecimal> toLevelProgress
(BigInteger total) Calculates the XP level and progress values from the total XP value.
-
Constructor Details
-
PlayerXPUtils
public PlayerXPUtils()
-
-
Method Details
-
setPlayerXPTotal
public static void setPlayerXPTotal(@NotNull @NotNull UUID uuid, @NotNull @NotNull BigInteger total) Sets a player's experience values to a specific balance.- Parameters:
uuid
- The player UUID.total
- The player balance.
-
setPlayerXPTotal
public static void setPlayerXPTotal(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull BigInteger total) Sets a player's experience values to a specific total.- Parameters:
player
- The player.total
- The player's XP total.
-
getPlayerXPTotal
Gets the total amount of XP a player has.- Parameters:
uuid
- The player's UUID.- Returns:
- The total amount of XP that the player has, rounded to the nearest whole number.
-
getPlayerXPTotal
Gets the total amount of XP a player has.- Parameters:
player
- The player.- Returns:
- The total amount of XP that the player has, rounded to the nearest whole number.
-
toLevelProgress
Calculates the XP level and progress values from the total XP value.- Parameters:
total
- A pair of a level and a progress percentage value.- Returns:
- The levels and progress for the given total.
-
getTotalXPValue
Gets the total amount of XP a player with the given level and level-up progress has.- Parameters:
level
- The player's current level count.progress
- The player's current progress to the next XP level.- Returns:
- The total amount of XP that the player has, rounded to the nearest whole number.
-
getXPForLevel
Calculates the total XP value for a given level. h/t to Minecraft Wiki. If this equation changes in-game, it will have to change here as well.- Parameters:
level
- The player's level.- Returns:
- The total XP value for the player's current level, rounded to a whole number.
-
getCurrentLevelProgress
Gets the current XP amount for the player's current progress towards leveling. h/t to Minecraft Wiki. If this equation changes in-game, it will have to change here as well.- Parameters:
level
- The player's current level.percent
- The current progress towards the next level.- Returns:
- The total XP the player currently has within the current level, rounded to a whole number.
-