Class PlayerXPUtils

java.lang.Object
dev.satyrn.xpeconomy.utils.PlayerXPUtils

public final class PlayerXPUtils extends Object
Performs XP conversion, calculation, and updating.
  • 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

      public static BigInteger getPlayerXPTotal(UUID uuid)
      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

      public static BigInteger getPlayerXPTotal(@NotNull @NotNull org.bukkit.entity.Player player)
      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

      public static org.javatuples.Pair<BigInteger,BigDecimal> toLevelProgress(BigInteger total)
      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

      public static BigInteger getTotalXPValue(int level, float progress)
      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

      public static BigInteger getXPForLevel(BigInteger level)
      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

      public static BigInteger getCurrentLevelProgress(BigInteger level, BigDecimal percent)
      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.