You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PlayerUtil class in LarroxUtilsAPI is a small utility designed to simplify player checks in your commands and plugin logic.
It helps determine whether a CommandSender is a Player or not.
Note
Don’t forget to import:
importdev.larrox.PlayerUtil;
🚀 Features
Check if a CommandSender is a Player.
Useful for command validation or player-only actions.
🛠️ Examples
Check if a sender is a player
if (!PlayerUtil.isPlayer(sender)) {
sender.sendMessage("§cYou must be a player to use this command!");
returntrue;
}
Playerplayer = (Player) sender;
player.sendMessage("§aHello, player!");
✅ Best Practices
Use PlayerUtil.isPlayer(sender)before casting a CommandSender to Player.
Always handle the case when the sender is not a player (e.g., console commands).
Combine with your own messaging utility for consistent plugin feedback.