Package ch.njol.skript.bukkitutil
Class PlayerUtils
java.lang.Object
ch.njol.skript.bukkitutil.PlayerUtils
Contains utility methods related to players
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canEat
(org.bukkit.entity.Player p, org.bukkit.Material food) static int
getCumulativeXP
(int level) Gets the cumulative experience needed to reach the given level, but no further.static int
getLevelXP
(int level) Gets the experience points needed to reach the next level, starting at the given level.static Collection
<? extends org.bukkit.entity.Player> Deprecated.static int
getTotalXP
(int level, double progress) Gets the total experience points needed to reach the given level, including the given progress.static int
getTotalXP
(org.bukkit.entity.Player player) Gets the total experience points of the given player.static void
setTotalXP
(org.bukkit.entity.Player player, int experience) Sets the total experience points of the given player.static void
updateInventory
(@Nullable org.bukkit.entity.Player player) Updates the clients inventory within a tick, usingPlayer.updateInventory()
.
-
Constructor Details
-
PlayerUtils
public PlayerUtils()
-
-
Method Details
-
updateInventory
public static void updateInventory(@Nullable @Nullable org.bukkit.entity.Player player) Updates the clients inventory within a tick, usingPlayer.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.useBukkit.getOnlinePlayers()
instead -
canEat
public static boolean canEat(org.bukkit.entity.Player p, org.bukkit.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 ofprogress
- 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(org.bukkit.entity.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(org.bukkit.entity.Player player, int experience) Sets the total experience points of the given player.- Parameters:
player
- The player to set the total XP ofexperience
- The total experience points to set
-
Bukkit.getOnlinePlayers()
instead