Interface Command
public interface Command
Represents a command in the Spigot plugin framework.
Provides methods for command execution, argument handling, and error management.
-
Method Summary
Modifier and TypeMethodDescriptionList<io.github.jwdeveloper.spigot.commands.api.argumetns.ArgumentProperties>Retrieves the list of arguments associated with this command.Retrieves a child command by its name, if it exists.children()Retrieves the list of child commands associated with this command.io.github.jwdeveloper.dependance.api.DependanceContainerRetrieves theDependanceContainerassociated with this command, which manages dependencies and services.voiddispatchError(io.github.jwdeveloper.spigot.commands.api.data.events.CommandErrorEvent errorEvent) Handles and dispatches errors that occur during command execution.default io.github.jwdeveloper.spigot.commands.api.data.ActionResult<io.github.jwdeveloper.spigot.commands.api.data.events.CommandEvent>executeCommand(String... arguments) Executes the command with the specified arguments from the console sender.io.github.jwdeveloper.spigot.commands.api.data.ActionResult<io.github.jwdeveloper.spigot.commands.api.data.events.CommandEvent>executeCommand(org.bukkit.command.CommandSender sender, String commandLabel, String... arguments) Executes the command with the specified sender, command label, and arguments.executeSuggestions(org.bukkit.command.CommandSender sender, String alias, String... args) Provides suggestions for command completion based on the sender, alias, and input arguments.booleanChecks if the command has a child command with the specified name.booleanChecks if this command has a parent command.name()Retrieves the name of the command.parent()Retrieves the parent command of this command, if it exists.io.github.jwdeveloper.spigot.commands.api.data.CommandPropertiesRetrieves the properties associated with this command, including name, description, and permissions.
-
Method Details
-
properties
io.github.jwdeveloper.spigot.commands.api.data.CommandProperties properties()Retrieves the properties associated with this command, including name, description, and permissions.- Returns:
- the
CommandPropertiesof the command
-
arguments
List<io.github.jwdeveloper.spigot.commands.api.argumetns.ArgumentProperties> arguments()Retrieves the list of arguments associated with this command.- Returns:
- a list of
ArgumentPropertiesdefining the command's arguments
-
children
Retrieves the list of child commands associated with this command.- Returns:
- a list of child
Commandobjects
-
hasChild
Checks if the command has a child command with the specified name.- Parameters:
name- the name of the child command- Returns:
- true if a child command with the specified name exists, false otherwise
-
child
Retrieves a child command by its name, if it exists.- Parameters:
name- the name of the child command- Returns:
- an
Optionalcontaining the child command if found, or empty if not found
-
executeCommand
io.github.jwdeveloper.spigot.commands.api.data.ActionResult<io.github.jwdeveloper.spigot.commands.api.data.events.CommandEvent> executeCommand(org.bukkit.command.CommandSender sender, String commandLabel, String... arguments) Executes the command with the specified sender, command label, and arguments.- Parameters:
sender- theCommandSenderwho issued the commandcommandLabel- the label of the command being executedarguments- the arguments passed to the command- Returns:
- an
ActionResultcontaining theCommandEventof the command execution
-
executeCommand
default io.github.jwdeveloper.spigot.commands.api.data.ActionResult<io.github.jwdeveloper.spigot.commands.api.data.events.CommandEvent> executeCommand(String... arguments) Executes the command with the specified arguments from the console sender.- Parameters:
arguments- the arguments passed to the command- Returns:
- an
ActionResultcontaining theCommandEventof the command execution
-
executeSuggestions
io.github.jwdeveloper.spigot.commands.api.data.ActionResult<List<String>> executeSuggestions(org.bukkit.command.CommandSender sender, String alias, String... args) Provides suggestions for command completion based on the sender, alias, and input arguments.- Parameters:
sender- theCommandSenderrequesting suggestionsalias- the alias of the command being usedargs- the arguments entered by the user so far- Returns:
- an
ActionResultcontaining a list of suggested strings
-
parent
Retrieves the parent command of this command, if it exists.- Returns:
- an
Optionalcontaining the parent command if available, or empty if no parent exists
-
hasParent
boolean hasParent()Checks if this command has a parent command.- Returns:
- true if a parent command exists, false otherwise
-
name
String name()Retrieves the name of the command.- Returns:
- the name of the command as a string
-
container
io.github.jwdeveloper.dependance.api.DependanceContainer container()Retrieves theDependanceContainerassociated with this command, which manages dependencies and services.- Returns:
- the associated
DependanceContainer
-
dispatchError
void dispatchError(io.github.jwdeveloper.spigot.commands.api.data.events.CommandErrorEvent errorEvent) Handles and dispatches errors that occur during command execution.- Parameters:
errorEvent- theCommandErrorEventcontaining details of the error
-