-
Notifications
You must be signed in to change notification settings - Fork 0
PlayerUtil
Larrox edited this page Aug 29, 2025
·
1 revision
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:
import dev.larrox.PlayerUtil;- Check if a
CommandSenderis aPlayer. - Useful for command validation or player-only actions.
if (!PlayerUtil.isPlayer(sender)) {
sender.sendMessage("§cYou must be a player to use this command!");
return true;
}
Player player = (Player) sender;
player.sendMessage("§aHello, player!");- Use
PlayerUtil.isPlayer(sender)before casting aCommandSendertoPlayer. - 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.