Class OptionalArgument<S extends CommandSource,T>
java.lang.Object
studio.mevera.imperat.util.TypeCapturer
studio.mevera.imperat.command.arguments.type.ArgumentType<S,Optional<T>>
studio.mevera.imperat.command.arguments.type.OptionalArgument<S,T>
- All Implemented Interfaces:
Prioritizable
-
Field Summary
Fields inherited from class studio.mevera.imperat.command.arguments.type.ArgumentType
suggestions, type -
Constructor Summary
ConstructorsConstructorDescriptionOptionalArgument(TypeWrap<Optional<T>> typeWrap, ArgumentType<S, T> typeResolver) -
Method Summary
Modifier and TypeMethodDescriptionReturns the default value supplier for the given source and command parameter.Returns the suggestion resolver associated with this parameter type.booleanDetermines if this parameter type is greedy, meaning it consumes multiple arguments.Parses the argument value from the given input string, using the provided execution context.parse(@NotNull ExecutionContext<S> context, @NotNull Cursor<S> cursor) Parses the argument value from the current position of the cursor, using the provided execution context.Methods inherited from class studio.mevera.imperat.command.arguments.type.ArgumentType
addStaticSuggestions, equalsExactly, getNumberOfParametersToConsume, getPriority, isRelatedToType, type, wrappedTypeMethods inherited from class studio.mevera.imperat.util.TypeCapturer
extractType, extractType
-
Constructor Details
-
OptionalArgument
-
-
Method Details
-
getSuggestionProvider
Description copied from class:ArgumentTypeReturns the suggestion resolver associated with this parameter type.- Overrides:
getSuggestionProviderin classArgumentType<S extends CommandSource,Optional<T>> - Returns:
- the suggestion resolver for generating suggestions based on the parameter type.
-
getDefaultValueProvider
Description copied from class:ArgumentTypeReturns the default value supplier for the given source and command parameter. By default, this returns an empty supplier, indicating no default value.- Overrides:
getDefaultValueProviderin classArgumentType<S extends CommandSource,Optional<T>> - Returns:
- an
DefaultValueProviderproviding the default value, or empty if none.
-
isGreedy
Description copied from class:ArgumentTypeDetermines if this parameter type is greedy, meaning it consumes multiple arguments. By default, returnsfalse.- Overrides:
isGreedyin classArgumentType<S extends CommandSource,Optional<T>> - Parameters:
parameter- the command parameter.- Returns:
trueif greedy,falseotherwise.
-
parse
public Optional<T> parse(@NotNull @NotNull CommandContext<S> context, @NotNull @NotNull Argument<S> argument, @NotNull @NotNull String input) throws CommandException, ResponseException Description copied from class:ArgumentTypeParses the argument value from the given input string, using the provided execution context. This method is responsible for converting the raw input into the appropriate type, handling any necessary validation or error handling during the parsing process.- Specified by:
parsein classArgumentType<S extends CommandSource,Optional<T>> - Parameters:
context- the execution context.argument- the argument with this type.input- the raw input string to parse.- Returns:
- the resolved value of type T.
- Throws:
CommandException- if parsing fails.ResponseException
-
parse
public Optional<T> parse(@NotNull @NotNull ExecutionContext<S> context, @NotNull @NotNull Cursor<S> cursor) throws CommandException, ResponseException Description copied from class:ArgumentTypeParses the argument value from the current position of the cursor, using the provided execution context. This method fetches the input from the cursor and delegates toArgumentType.parse(CommandContext, Argument, String). This is the main entry point for argument parsing during command execution.- Overrides:
parsein classArgumentType<S extends CommandSource,Optional<T>> - Parameters:
context- the execution context.cursor- the command input stream.- Returns:
- the resolved value of type T.
- Throws:
CommandException- if parsing fails.ResponseException
-