Interface ICommandSender
- All Superinterfaces:
IMessageable
- All Known Implementing Classes:
SpigotServer, WrappedOfflinePlayer, WrappedPlayer
Represents a command sender. This may be a player or any kind of non-player entity that can issue commands (e.g. the
server, a command block, etc.).
-
Method Summary
Modifier and TypeMethodDescriptionformatCommand(String commandName, String subCommandFormat, @Nullable Object @Nullable ... args) Formats a command appropriately for this command sender.Gets theIPlayerthat issued the command.default CompletableFuture<Boolean> hasPermission(String permission) Checks if this sender has a given permission.default CompletableFuture<PermissionsStatus> hasPermission(CommandDefinition command) Checks if this sender has a given command.booleanisPlayer()Checks if the command sender is a player.Methods inherited from interface IMessageable
getPersonalizedLocalizer, getTextFactory, newText, sendError, sendInfo, sendMessage, sendMessage, sendSuccess
-
Method Details
-
getPlayer
-
isPlayer
boolean isPlayer()Checks if the command sender is a player.- Returns:
- True if the command sender is a player.
-
formatCommand
@FormatMethod @CheckReturnValue String formatCommand(String commandName, @FormatString String subCommandFormat, @Nullable Object @Nullable ... args) Formats a command appropriately for this command sender.Players receive commands with a leading slash (e.g., "/command"), while non-players (console, command blocks) receive commands without the leading slash (e.g., "command").
- Parameters:
commandName- The name of the command (without leading slash).subCommandFormat- The format string for the subcommand and its arguments.args- Arguments referenced by the format specifiers in the subcommand format string.- Returns:
- The formatted command appropriate for this sender.
-
hasPermission
Checks if this sender has a given permission.- Parameters:
permission- The permission node to check.- Returns:
- True if the player has access to the provided permission, otherwise false.
-
hasPermission
Checks if this sender has a given command.Both the user permission (See
CommandDefinition.getUserPermission()) and the admin permission (SeeCommandDefinition.getAdminPermission()) are checked.- Parameters:
command- TheCommandDefinitionof a command to check.- Returns:
- A
PermissionsStatusthat is true if the player has access to the provided permissions, otherwise false for the user and the admin permission nodes respectively.
-