Interface CommandPathway<S extends CommandSource>
- All Superinterfaces:
CooldownHolder,DescriptionHolder,Iterable<Argument<S>>,PermissionHolder
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classCommandPathway.Builder<S extends CommandSource> -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArguments(List<Argument<S>> params) Adds parameters to the usagevoidaddArguments(Argument<S>... params) Adds parameters to the usagevoidaddExample(String example) Adds an example to the usagedefault voidaddExamples(List<String> examples) default voidvoidaddFlag(FlagArgument<S> flagArgumentData) Adds a free flag to the usagestatic <S extends CommandSource>
CommandPathway.Builder<S>builder()static <S extends CommandSource>
CommandPathway.Builder<S>builder(@Nullable MethodElement methodElement) voidExecutes the usage's actions using the suppliedCommandCoordinatorstatic <S extends CommandSource>
Stringformat(@Nullable String label, CommandPathway<S> usage) static <S extends CommandSource>
Stringformat(@Nullable Command<S> command, CommandPathway<S> usage) default Stringstatic <S extends CommandSource>
StringformatWithTypes(Command<S> command, CommandPathway<S> usage) getArgumentAt(int index) Fetches the parameter at the indexgetArgumentAt(Predicate<Argument<S>> parameterPredicate) @NotNull CooldownHandler<S>The pre-defined syntax examples for this usage.@NotNull CommandExecution<S>@NotNull FlagExtractor<S>Retrieves the flag extractor instance for parsing command flags from input strings.getFlagParameterFromRaw(String rawInput) Fetches the flag from the inputint@Nullable MethodElementintbooleanChecks whether the raw input is a flag registered by this usagebooleanhasParameters(Predicate<Argument<S>> parameterPredicate) Searches for a parameter with specific valueTypebooleanhasParameters(List<Argument<S>> parameters) booleanhasParamType(Class<?> clazz) default booleanvoidsetCooldownHandler(CooldownHandler<S> cooldownHandler) Sets the cooldown handlerCooldownHandlervoidsetCoordinator(CommandCoordinator<S> commandCoordinator) Sets the command coordinatordefault intsize()Methods inherited from interface studio.mevera.imperat.command.CooldownHolder
getCooldown, setCooldown, setCooldown, setCooldownMethods inherited from interface studio.mevera.imperat.command.DescriptionHolder
describe, describe, getDescriptionMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface studio.mevera.imperat.permissions.PermissionHolder
getPermissionsData, getPrimaryPermission, setPermissionData
-
Method Details
-
formatWithTypes
static <S extends CommandSource> String formatWithTypes(Command<S> command, CommandPathway<S> usage) -
format
static <S extends CommandSource> String format(@Nullable @Nullable String label, CommandPathway<S> usage) -
format
static <S extends CommandSource> String format(@Nullable @Nullable Command<S> command, CommandPathway<S> usage) -
builder
-
builder
static <S extends CommandSource> CommandPathway.Builder<S> builder(@Nullable @Nullable MethodElement methodElement) -
getMethodElement
-
getFlagExtractor
Retrieves the flag extractor instance for parsing command flags from input strings.The returned
FlagExtractoris capable of parsing flag aliases from compact string representations (e.g., "-abc", "alphaby") and resolving them to their correspondingFlagDataobjects based on the command's usage configuration.The extractor uses a greedy longest-match algorithm to handle overlapping aliases efficiently. For example, if both "a" and "alpha" are valid aliases for the same flag, the input "alpha" will match the longer alias rather than just "a".
Usage Examples:
// Given flags: alpha["a", "alfa"], beta["b"], gamma["g", "gam"] FlagExtractor<MySource> extractor = command.getFlagExtractor(); Set<FlagData<MySource>> flags1 = extractor.extract("ab"); // alpha, beta Set<FlagData<MySource>> flags2 = extractor.extract("alphag"); // alpha, gamma Set<FlagData<MySource>> flags3 = extractor.extract("abx"); // throws UnknownFlagExceptionError Handling: The extractor will throw an
CommandExceptionif the input contains any characters that cannot be matched to known flag aliases.Thread Safety: The returned extractor instance is thread-safe for concurrent read operations but should not be used across different command contexts.
- Returns:
- a non-null flag extractor configured for this command's flag definitions
- Throws:
IllegalStateException- if the command usage has not been properly initialized or if no flag definitions are available- Since:
- 1.9.6
- See Also:
-
hasFlag
Checks whether the raw input is a flag registered by this usage- Parameters:
input- the raw input- Returns:
- Whether the input is a flag and is registered in the usage
-
getFlagParameterFromRaw
Fetches the flag from the input- Parameters:
rawInput- the input- Returns:
- the flag from the raw input, null if it cannot be a flag
-
addFlag
-
addFlag
Adds a free flag to the usage- Parameters:
flagArgumentData- adds a free flag to the usage
-
addArguments
Adds parameters to the usage- Parameters:
params- the parameters to add
-
addArguments
Adds parameters to the usage- Parameters:
params- the parameters to add
-
getArguments
- Returns:
- the parameters for this usage
- See Also:
-
getExamples
The pre-defined syntax examples for this usage.- Returns:
- the pre-defined examples for this
CommandPathway
-
addExample
Adds an example to the usage- Parameters:
example- the example to add using this usage.
-
addExamples
-
getArgumentAt
Fetches the parameter at the index- Parameters:
index- the index of the parameter- Returns:
- the parameter at specified index/position
-
getExecution
- Returns:
- the execution for this usage
-
hasParamType
- Parameters:
clazz- the valueType of the parameter to check upon- Returns:
- Whether the usage has a specific valueType of parameter
-
getMinLength
int getMinLength()- Returns:
- Gets the minimal possible number of parameters that are acceptable to initiate this usage of a command.
-
getMaxLength
int getMaxLength()- Returns:
- Gets the maximum possible number of parameters that are acceptable to initiate this usage of a command.
-
hasParameters
Searches for a parameter with specific valueType- Parameters:
parameterPredicate- the parameter condition- Returns:
- whether this usage has atLeast on
Argumentwith specific condition or not
-
getArgumentAt
- Parameters:
parameterPredicate- the condition- Returns:
- the parameter to get using a condition
-
getCooldownHandler
- Returns:
- the cool down handler
CooldownHandler
-
setCooldownHandler
Sets the cooldown handlerCooldownHandler- Parameters:
cooldownHandler- the cool down handler to set
-
isDefault
default boolean isDefault() -
getCoordinator
CommandCoordinator<S> getCoordinator()- Returns:
- the coordinator for execution of the command
-
setCoordinator
Sets the command coordinator- Parameters:
commandCoordinator- the coordinator to set
-
execute
Executes the usage's actions using the suppliedCommandCoordinator- Parameters:
imperat- the apisource- the command source/sendercontext- the context of the command- Throws:
CommandException
-
hasParameters
- Parameters:
parameters- the parameters- Returns:
- whether this usage has this sequence of parameters
-
size
default int size() -
formatted
-
getLastArgument
-
getParametersWithFlags
-