Package revxrsal.commands.command
Interface CommandActor
- All Known Subinterfaces:
BukkitCommandActor
,BungeeCommandActor
,ConsoleActor
,JDAActor
,SpongeCommandActor
,VelocityCommandActor
- All Known Implementing Classes:
BaseActorJDA
,BukkitActor
,BungeeActor
,CommandLineActor
,SpongeActor
,VelocityActor
public interface CommandActor
Represents a command sender, responsible for performing a command-related
action.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends CommandActor>
TReturns this actor as the specified type.void
Replies to the sender with the specified message, and marks it as an error depending on the platform.default void
errorLocalized
(@NotNull String key, Object... args) Replies with the given messageReturns the command handler that constructed this actordefault @NotNull Locale
Returns the locale of this command actor.@NotNull String
getName()
Returns the name of this actor.default Translator
Shortcut toCommandHandler.getTranslator()
@NotNull UUID
Returns the unique UID of this subject.void
Replies to the sender with the specified message.default void
replyLocalized
(@NotNull String key, Object... args) Replies with the given message
-
Method Details
-
getName
Returns the name of this actor. Varies depending on the platform.- Returns:
- The actor name
-
getUniqueId
Returns the unique UID of this subject. Varies depending on the platform.Although some platforms explicitly have their underlying senders have UUIDs, some platforms may have to generate this UUID based on other available data.
- Returns:
- The UUID of this subject.
-
reply
Replies to the sender with the specified message.Varies depending on the platform.
- Parameters:
message
- Message to reply with.
-
error
Replies to the sender with the specified message, and marks it as an error depending on the platform.Note that, in certain platforms where no "error" mode is available, this may effectively be equivilent to calling
reply(String)
.This method should not throw any exceptions.
- Parameters:
message
- Message to reply with
-
getCommandHandler
CommandHandler getCommandHandler()Returns the command handler that constructed this actor- Returns:
- The command handler
-
getTranslator
Shortcut toCommandHandler.getTranslator()
- Returns:
- The command handler translator
-
getLocale
Returns the locale of this command actor. This can be used by translation tools to provide specialized messages.Note that platforms that do not support per-actor locales will return a default locale, mostly
Locale.ENGLISH
.- Returns:
- The actor's locale
-
replyLocalized
Replies with the given message- Parameters:
key
- Key of the messageargs
- The arguments to format with
-
errorLocalized
Replies with the given message- Parameters:
key
- Key of the messageargs
- The arguments to format with
-
as
Returns this actor as the specified type. This is effectively casting this actor to the given type.- Type Parameters:
T
- The actor type- Parameters:
type
- Type to cast to- Returns:
- This actor but casted.
-