CommandSender
Package: com.hypixel.hytale.server.core.command.system
public interface CommandSender extends IMessageReceiver, PermissionHolderInterface representing the entity that executed a command. Extends IMessageReceiver (can receive messages) and PermissionHolder (has permissions). Implemented by Player and the server console.
Methods
Section titled “Methods”String getDisplayName();Returns the display name of the sender (e.g., the player’s username or "Console").
UUID getUuid();Returns the sender’s UUID.
Inherited Methods
Section titled “Inherited Methods”From IMessageReceiver
Section titled “From IMessageReceiver”void sendMessage(Message message);Sends a formatted message to the sender.
From PermissionHolder
Section titled “From PermissionHolder”boolean hasPermission(String permission);Checks whether the sender has a specific permission.
Known Implementors
Section titled “Known Implementors”| Class | Context |
|---|---|
Player | In-game player executing a command |
| Server console | Console command input |
CommandSender is accessed through CommandContext.sender():
@Overrideprotected void executeSync(@Nonnull CommandContext context) { CommandSender sender = context.sender();
// Check sender type if (context.isPlayer()) { Player player = context.senderAs(Player.class); // player-specific logic }
// Send response (works for any sender type) sender.sendMessage(Message.raw("Hello, " + sender.getDisplayName()));
// Check permissions if (sender.hasPermission("myplugin.admin")) { // admin-only logic }}Related
Section titled “Related”- CommandContext — Provides
sender()accessor - AbstractCommand — Permission checking via
hasPermission(CommandSender) - Player — Primary implementor; the in-game player entity
- Command System Overview — Full command system documentation