Class KamiCommand
java.lang.Object
com.kamikazejam.kamicommon.command.KamiCommand
- All Implemented Interfaces:
Active,PluginIdentifiableCommand
- Direct Known Subclasses:
CmdGetItem,CmdItemDump,CmdLoadItem,CmdNmsTest,CmdNmsVersion,CmdOpenMenu,CmdReload,CmdSaveItem,CmdSubsystems,CmdTestMsg,KamiCommandHelp,KamiCommandVersion,KamiCommonCommand,UnmatchedCommand
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMessage and Color configuration for KamiCommand messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAliases(String @NotNull ... aliases) voidaddAliases(Collection<String> aliases) voidaddChild(KamiCommand child) voidaddChild(KamiCommand child, int index) voidaddChildAfter(KamiCommand child, KamiCommand after) <T> @NotNull Parameter<T> addParameter(@NotNull Parameter<T> parameter) <T> @NotNull Parameter<T> addParameter(Parameter.Builder<T> parameter) voidaddRequirements(Requirement @NotNull ... requirements) voidaddRequirements(Collection<Requirement> requirements) applyConcatenating(List<String> args) booleanargIsSet()booleanargIsSet(int idx) final voidexecute(@NotNull CommandSender sender, @NotNull String label, @NotNull List<String> args) @NotNull KamiPluginstatic Set<KamiCommand> @Nullable StringNOTICE: This Method is only relevant if this command is used as a ROOT COMMAND.
Get the permission that should be used for this command in Bukkit.
(This is the permission sent toCommand.setPermission(String)when the command is registered)
Set a custom permission usingsetBukkitCommandPermission(String).
If no custom permission is set, then the permission is derived from theRequirementHasPermrequirements set on the command.
(If noRequirementHasPermrequirements are found, this command will not require any permission to execute)getChain(boolean includeSelf) Returns the chain of commands leading to this command, like a stack trace.
The first element will be the root command.getCommandLine(Iterable<String> args) int@NotNull StringReturns the current command ran by the player.@NotNull StringReturns the current template chain for this command.@NotNull StringgetCurrentTemplateUsageMini(@NotNull CommandSender sender, boolean addDesc) Returns the current template usage for this command.getDesc()@NotNull StringgetFullTemplate(boolean addDesc, boolean onlyFirstAlias, boolean onlyOneSubAlias, @Nullable CommandSender sender) @NotNull VersionedComponentgetHelpClickable(@NotNull KamiCommand child, @NotNull CommandSender sender) @NotNull StringgetHelpCommandLine(@NotNull KamiCommand child) Given a subcommand (a child of this command), returns a fully qualified command line that includes the current command chain and the suggested subcommand alias.intParameter<?> getParameter(int index) intgetParameterCount(CommandSender sender) intintType<?> getParameterType(int index) getParents(boolean includeSelf) Returns all parents of this command, like a stack trace.
The first element will be this command.@NotNull Plugin@Nullable VersionedComponentgetRequirementsError(@NotNull CommandSender sender, boolean verbose) getRoot()@NotNull VersionedComponentgetSuggestionClickable(@NotNull KamiCommand suggested, @NotNull String token, @NotNull CommandSender sender) @NotNull StringgetSuggestionCommandLine(@NotNull KamiCommand suggested, @NotNull String token) Given a suggested subcommand (a child of this command), returns a fully qualified command line that includes the current command chain and the suggested subcommand alias.
The subcommand alias is chosen based on the provided token, which is expected to be a prefix of the alias.getTabCompletions(List<String> args, CommandSender sender) getTabCompletionsArg(List<String> args, CommandSender sender) getTabCompletionsChild(@NotNull List<String> args, CommandSender sender) getTemplateParameters(@Nullable CommandSender sender) getVisibleChildren(CommandSender watcher) booleanbooleanhasParameterForIndex(int index) booleanbooleanisActive()booleanisChild()booleanisFullChainMet(CommandSender sender) booleanisLeaf()booleanisParent()protected booleanisRelevant(CommandSender sender) booleanisRequirementsMet(@NotNull CommandSender sender, boolean verbose) booleanisRoot()booleanisVisibleTo(CommandSender sender) voidonUnmatchedArg(@NotNull CommandContext context) voidperform(@NotNull CommandContext context) <T> TreadArg()<T> TreadArg(T defaultNotSet) voidregisterCommand(KamiPlugin plugin) If you register a command after the server has started, you must call the following method:
KamiCommonCommandRegistration.updateRegistrations()
In order for the command to be added to the server.intremoveChild(KamiCommand child) voidintreplaceChild(KamiCommand child, KamiCommand replaced) voidsetActive(boolean active) voidsetActive(@Nullable KamiPlugin plugin) voidsetActivePlugin(KamiPlugin activePlugin) voidsetAliases(String @NotNull ... aliases) voidsetAliases(Collection<String> aliases) voidsetBukkitCommandPermission(@Nullable String permission) NOTICE: This Method is only relevant if this command is used as a ROOT COMMAND.
Override the default command permission parsing.
(The permission sent toCommand.setPermission(String)
By default, the permission is derived from anyRequirementHasPermrequirements set on the command.
You can optionally set a custom permission to use instead of the derived one.
Note:
- Setting this to null will cause the derived permission to be used again
- The only way to get a 'permission-less' command is to ensure there are noRequirementHasPermrequirements.voidsetConcatenating(boolean concatenating) voidvoidsetHelpComments(@NotNull VersionedComponent... helpComments) voidsetHelpComments(@NotNull List<VersionedComponent> helpComments) voidsetOverflowSensitive(boolean overflowSensitive) voidsetParameter(int index, Parameter<?> parameter) voidsetParent(KamiCommand parent) voidsetRequirements(List<Requirement> requirements) voidsetSwapping(boolean swapping) voidsetTokenizing(boolean tokenizing) voidsetUnsmart(boolean unsmart) voidIf you unregister a command after the server has started, you must call the following method:voidvalidateActiveAndRoot(Boolean active, Boolean root)
-
Constructor Details
-
KamiCommand
public KamiCommand()
-
-
Method Details
-
getAllInstances
-
registerCommand
If you register a command after the server has started, you must call the following method:
KamiCommonCommandRegistration.updateRegistrations()
In order for the command to be added to the server. -
unregisterCommand
public void unregisterCommand()If you unregister a command after the server has started, you must call the following method:- See Also:
-
isActive
public boolean isActive() -
setActive
public void setActive(boolean active) -
setActivePlugin
- Specified by:
setActivePluginin interfaceActive
-
getActivePlugin
- Specified by:
getActivePluginin interfaceActive
-
setActive
-
validateActiveAndRoot
-
getPlugin
- Specified by:
getPluginin interfacePluginIdentifiableCommand
-
hasParent
public boolean hasParent() -
isChild
public boolean isChild() -
isRoot
public boolean isRoot() -
hasChildren
public boolean hasChildren() -
isParent
public boolean isParent() -
isLeaf
public boolean isLeaf() -
getVisibleChildren
-
getRoot
-
getParents
Returns all parents of this command, like a stack trace.
The first element will be this command. The root command is last in the list. -
getChain
Returns the chain of commands leading to this command, like a stack trace.
The first element will be the root command. This command is last in the list. -
removeParent
public void removeParent() -
setParent
-
addChild
-
addChildAfter
-
replaceChild
-
removeChild
-
addChild
-
getHelpCommand
-
getChild
-
isRelevant
-
setAliases
-
setAliases
-
addAliases
-
addAliases
-
getParameter
-
getParameterType
-
setParameter
-
hasParameterForIndex
public boolean hasParameterForIndex(int index) -
getPageParameterIndex
public int getPageParameterIndex() -
getParameterCount
-
getParameterCountRequired
-
getParameterCountOptional
-
addParameter
-
addParameter
@Contract(mutates="this") @NotNull public <T> @NotNull Parameter<T> addParameter(@NotNull Parameter.Builder<T> parameter) -
setTokenizing
@Contract(mutates="this") public void setTokenizing(boolean tokenizing) -
setUnsmart
@Contract(mutates="this") public void setUnsmart(boolean unsmart) -
setOverflowSensitive
@Contract(mutates="this") public void setOverflowSensitive(boolean overflowSensitive) -
setConcatenating
@Contract(mutates="this") public void setConcatenating(boolean concatenating) -
getConcatenationIndex
public int getConcatenationIndex() -
setSwapping
@Contract(mutates="this") public void setSwapping(boolean swapping) -
setRequirements
-
addRequirements
-
addRequirements
-
isRequirementsMet
-
getRequirementsError
@Nullable public @Nullable VersionedComponent getRequirementsError(@NotNull @NotNull CommandSender sender, boolean verbose) -
setDesc
-
getDesc
-
getDescPermission
-
isVisibleTo
-
execute
public final void execute(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull List<String> args) - Parameters:
label- The specific label (or 'alias') used for this KamiCommand.
-
perform
- Throws:
KamiCommonException
-
getSuggestionClickable
@NotNull public @NotNull VersionedComponent getSuggestionClickable(@NotNull @NotNull KamiCommand suggested, @NotNull @NotNull String token, @NotNull @NotNull CommandSender sender) - Parameters:
suggested- The command that should be suggested to the user. (subcommand of this command)token- The token used that triggered this possible suggestion. (likely a partial alias)
-
getSuggestionCommandLine
@NotNull public @NotNull String getSuggestionCommandLine(@NotNull @NotNull KamiCommand suggested, @NotNull @NotNull String token) Given a suggested subcommand (a child of this command), returns a fully qualified command line that includes the current command chain and the suggested subcommand alias.
The subcommand alias is chosen based on the provided token, which is expected to be a prefix of the alias. -
getHelpClickable
@NotNull public @NotNull VersionedComponent getHelpClickable(@NotNull @NotNull KamiCommand child, @NotNull @NotNull CommandSender sender) - Parameters:
child- The command that should be suggested to the user. (subcommand of this command)
-
getHelpCommandLine
Given a subcommand (a child of this command), returns a fully qualified command line that includes the current command chain and the suggested subcommand alias. -
getCurrentTemplateChainMini
Returns the current template chain for this command. Requires an active command instance with non-null context.
The chain is the color coded concatenation of all command labels thus far (no parameters or descriptions). -
getCurrentTemplateUsageMini
@NotNull public @NotNull String getCurrentTemplateUsageMini(@NotNull @NotNull CommandSender sender, boolean addDesc) Returns the current template usage for this command. Requires an active command instance with non-null context.
The usage is the color coded concatenation of all command labels thus far, followed by parameters and description. -
getCurrentCommandLine
Returns the current command ran by the player. Requires an active command instance with non-null context.
Includes a leading slash. -
getFullTemplate
@NotNull public @NotNull String getFullTemplate(boolean addDesc, boolean onlyFirstAlias, boolean onlyOneSubAlias, @Nullable @Nullable CommandSender sender) -
isFullChainMet
-
onUnmatchedArg
-
getTemplateParameters
@NotNull protected @NotNull List<String> getTemplateParameters(@Nullable @Nullable CommandSender sender) -
getCommandLine
-
getTabCompletions
@Contract("null, _ -> fail; !null, null -> fail") public List<String> getTabCompletions(List<String> args, CommandSender sender) -
getTabCompletionsChild
protected List<String> getTabCompletionsChild(@NotNull @NotNull List<String> args, CommandSender sender) -
getTabCompletionsArg
-
applyConcatenating
-
argIsSet
public boolean argIsSet(int idx) -
argIsSet
public boolean argIsSet() -
readArg
- Throws:
KamiCommonException
-
readArg
- Throws:
KamiCommonException
-
setHelpComments
-
setHelpComments
-
setBukkitCommandPermission
NOTICE: This Method is only relevant if this command is used as a ROOT COMMAND.
Override the default command permission parsing.
(The permission sent toCommand.setPermission(String)
By default, the permission is derived from anyRequirementHasPermrequirements set on the command.
You can optionally set a custom permission to use instead of the derived one.
Note:
- Setting this to null will cause the derived permission to be used again
- The only way to get a 'permission-less' command is to ensure there are noRequirementHasPermrequirements. -
getBukkitCommandPermission
NOTICE: This Method is only relevant if this command is used as a ROOT COMMAND.
Get the permission that should be used for this command in Bukkit.
(This is the permission sent toCommand.setPermission(String)when the command is registered)
Set a custom permission usingsetBukkitCommandPermission(String).
If no custom permission is set, then the permission is derived from theRequirementHasPermrequirements set on the command.
(If noRequirementHasPermrequirements are found, this command will not require any permission to execute)
-