Class PlayerUtils

java.lang.Object
ch.njol.skript.bukkitutil.PlayerUtils

public abstract class PlayerUtils extends Object
Contains utility methods related to players
  • Constructor Details

    • PlayerUtils

      public PlayerUtils()
  • Method Details

    • updateInventory

      public static void updateInventory(@Nullable @Nullable Player player)
      Updates the clients inventory within a tick, using Player.updateInventory(). Recommended over directly calling the update method, as multiple calls to this method within a short timespan will not send multiple updates to the client.
    • getOnlinePlayers

      @Deprecated public static Collection<? extends Player> getOnlinePlayers()
      Deprecated.
    • canEat

      public static boolean canEat(Player p, Material food)
    • getLevelXP

      public static int getLevelXP(int level)
      Gets the experience points needed to reach the next level, starting at the given level. E.g. getLevelXP(30) returns the experience points needed to reach level 31 from level 30.
      Parameters:
      level - The starting level
      Returns:
      The experience points needed to reach the next level
    • getCumulativeXP

      public static int getCumulativeXP(int level)
      Gets the cumulative experience needed to reach the given level, but no further. E.g. getCumulativeXP(30) returns the experience points needed to reach level 30 from level 0.
      Parameters:
      level - The level to get the cumulative XP for
      Returns:
      The experience points needed to reach the given level
    • getTotalXP

      public static int getTotalXP(int level, double progress)
      Gets the total experience points needed to reach the given level, including the given progress. E.g. getTotalXP(30, 0.5) returns the experience points needed to reach level 30 from level 0, and have a half-full xp bar.
      Parameters:
      level - The level to get the total XP of
      progress - The progress towards the next level, between 0 and 1
      Returns:
      The total experience points needed to reach the given level and progress
    • getTotalXP

      public static int getTotalXP(Player player)
      Gets the total experience points of the given player.
      Parameters:
      player - The player to get the total XP of
      Returns:
      The total experience points of the given player
    • setTotalXP

      public static void setTotalXP(Player player, int experience)
      Sets the total experience points of the given player.
      Parameters:
      player - The player to set the total XP of
      experience - The total experience points to set