Package dev.hypera.chameleon.command
Class Command
- java.lang.Object
-
- dev.hypera.chameleon.command.Command
-
public abstract class Command extends Object
Abstract command.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddAliases(@NotNull Collection<String> aliases)Add command aliases.abstract voidexecute(@NotNull Context context)Execute the command.voidexecuteCommand(@NotNull Context context)Execute the command.booleanexecuteSubCommand(@NotNull Context context, @NotNull String command)Execute sub command.@NotNull Collection<String>getAliases()Get command aliases.protected @NotNull Collection<Condition>getConditions()Get command conditions.@NotNull StringgetName()Get command name.protected @NotNull Optional<Permission>getPermission()Get permission.protected @NotNull Optional<net.kyori.adventure.text.Component>getPermissionErrorMessage()Get command permission error message.@NotNull PlatformTargetgetPlatform()Get the platform target of this command.@NotNull Collection<SubCommand>getSubCommands()Get sub-commands.protected voidsetConditions(@NotNull Condition... conditions)Set command conditions.protected voidsetPermissionErrorMessage(@NotNull net.kyori.adventure.text.Component permissionErrorMessage)Set command permission error message.protected voidsetPlatform(@NotNull PlatformTarget platform)Set the platform target of this command.@NotNull Collection<String>tabComplete(@NotNull Context context)Tab complete.
-
-
-
Constructor Detail
-
Command
protected Command(@NotNull @NotNull String... names)Command constructor.- Parameters:
names- Command aliases.
-
-
Method Detail
-
execute
public abstract void execute(@NotNull @NotNull Context context)Execute the command.- Parameters:
context- Execution context.
-
tabComplete
@NotNull public @NotNull Collection<String> tabComplete(@NotNull @NotNull Context context)
Tab complete.- Parameters:
context- Execution context.- Returns:
- Tab complete results.
-
executeCommand
@Internal public final void executeCommand(@NotNull @NotNull Context context)Execute the command.- Parameters:
context- Execution context.
-
executeSubCommand
@Internal public final boolean executeSubCommand(@NotNull @NotNull Context context, @NotNull @NotNull String command)Execute sub command.- Parameters:
context- Execution context.command- Sub-command name.- Returns:
trueif a sub-command was found and executed, otherwisefalse.
-
getName
@NotNull public final @NotNull String getName()
Get command name.- Returns:
- Command name.
-
getAliases
@NotNull public final @NotNull Collection<String> getAliases()
Get command aliases.- Returns:
- command aliases.
-
addAliases
protected final void addAliases(@NotNull @NotNull Collection<String> aliases)Add command aliases.- Parameters:
aliases- Command aliases.
-
getSubCommands
@Internal @NotNull public final @NotNull Collection<SubCommand> getSubCommands()
Get sub-commands.- Returns:
- sub-commands.
-
getPermission
@NotNull protected final @NotNull Optional<Permission> getPermission()
Get permission.- Returns:
- an optional containing the command permission, if available, otherwise an empty optional.
-
getPlatform
@NotNull public final @NotNull PlatformTarget getPlatform()
Get the platform target of this command.- Returns:
- platform target.
-
setPlatform
protected final void setPlatform(@NotNull @NotNull PlatformTarget platform)Set the platform target of this command.- Parameters:
platform- platform target.
-
getConditions
@NotNull protected final @NotNull Collection<Condition> getConditions()
Get command conditions.- Returns:
- command conditions.
-
setConditions
protected final void setConditions(@NotNull @NotNull Condition... conditions)Set command conditions.- Parameters:
conditions- Command conditions.
-
getPermissionErrorMessage
@NotNull protected final @NotNull Optional<net.kyori.adventure.text.Component> getPermissionErrorMessage()
Get command permission error message.- Returns:
- command permission error message.
-
setPermissionErrorMessage
protected final void setPermissionErrorMessage(@NotNull @NotNull net.kyori.adventure.text.Component permissionErrorMessage)Set command permission error message.- Parameters:
permissionErrorMessage- Command permission error message.
-
-