Package revxrsal.commands.bukkit
Interface BukkitCommandActor
- All Superinterfaces:
CommandActor
- All Known Implementing Classes:
BukkitActor
Represents a Bukkit
CommandActor
that wraps CommandSender
-
Method Summary
Modifier and TypeMethodDescription@NotNull net.kyori.adventure.audience.Audience
audience()
Returns theAudience
of this sender.@Nullable org.bukkit.entity.Player
Returns this actor as aPlayer
if it is a player, otherwise returnsnull
.Returns the command handler that constructed this actor@NotNull org.bukkit.command.CommandSender
Returns the underlyingCommandSender
of this actorboolean
Tests whether is this actor the console or notboolean
isPlayer()
Tests whether is this actor a player or notvoid
reply
(@NotNull net.kyori.adventure.text.ComponentLike component) Sends the given component to this actor.@NotNull org.bukkit.command.ConsoleCommandSender
Returns this actor as aConsoleCommandSender
if it is a player, otherwise throws aSenderNotConsoleException
.@NotNull org.bukkit.entity.Player
Returns this actor as aPlayer
if it is a player, otherwise throws aSenderNotPlayerException
.static @NotNull BukkitCommandActor
wrap
(@NotNull org.bukkit.command.CommandSender sender, @NotNull CommandHandler handler) Creates a newBukkitCommandActor
that wraps the givenCommandSender
.Methods inherited from interface revxrsal.commands.command.CommandActor
as, error, errorLocalized, getLocale, getName, getTranslator, getUniqueId, reply, replyLocalized
-
Method Details
-
getSender
@NotNull @NotNull org.bukkit.command.CommandSender getSender()Returns the underlyingCommandSender
of this actor- Returns:
- The sender
-
isPlayer
boolean isPlayer()Tests whether is this actor a player or not- Returns:
- Is this a player or not
-
isConsole
boolean isConsole()Tests whether is this actor the console or not- Returns:
- Is this the console or not
-
getAsPlayer
@Nullable @Nullable org.bukkit.entity.Player getAsPlayer()Returns this actor as aPlayer
if it is a player, otherwise returnsnull
.- Returns:
- The sender as a player, or null.
-
requirePlayer
Returns this actor as aPlayer
if it is a player, otherwise throws aSenderNotPlayerException
.- Returns:
- The actor as a player
- Throws:
SenderNotPlayerException
- if not a player
-
requireConsole
@NotNull @NotNull org.bukkit.command.ConsoleCommandSender requireConsole() throws SenderNotConsoleExceptionReturns this actor as aConsoleCommandSender
if it is a player, otherwise throws aSenderNotConsoleException
.- Returns:
- The actor as console
- Throws:
SenderNotConsoleException
- if not a player
-
audience
@NotNull @NotNull net.kyori.adventure.audience.Audience audience()Returns theAudience
of this sender.NOTE: This requires calling
BukkitCommandHandler.enableAdventure()
orBukkitCommandHandler.enableAdventure(BukkitAudiences)
.- Returns:
- The audience of this sender
- Throws:
IllegalStateException
- ifenableAdventure
was not called.
-
reply
void reply(@NotNull @NotNull net.kyori.adventure.text.ComponentLike component) Sends the given component to this actor.NOTE: This requires calling
BukkitCommandHandler.enableAdventure()
orBukkitCommandHandler.enableAdventure(BukkitAudiences)
.- Parameters:
component
- Component to send- Throws:
IllegalStateException
- ifenableAdventure
was not called.
-
getCommandHandler
BukkitCommandHandler getCommandHandler()Returns the command handler that constructed this actor- Specified by:
getCommandHandler
in interfaceCommandActor
- Returns:
- The command handler
-
wrap
@NotNull static @NotNull BukkitCommandActor wrap(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull CommandHandler handler) Creates a newBukkitCommandActor
that wraps the givenCommandSender
.- Parameters:
sender
- Command sender to wrap- Returns:
- The wrapping
BukkitCommandActor
.
-