Class CommandContext<S>
java.lang.Object
io.github.mqzn.commands.base.context.CommandContext<S>
- All Implemented Interfaces:
Context<S>
-
Method Summary
Modifier and TypeMethodDescriptionThe command found and used in the context made by the command senderstatic <S> CommandContext<S>create(@NotNull CommandManager<?, S> manager, @NotNull CommandSyntax<S> syntax, @NotNull DelegateCommandContext<S> context) @NotNull ContextFlagRegistry<S>flags()The flags used in the commandintFetches the number of flags used in the raw arguments<T> TgetArgument(int index) Fetches the parsed argument value may return null if the value parsed is not valid some cases of failed argument parsing may be like this one: an integer argument with min of 1 and max of 10, however the input was "one" or may be "-1" which is not a valid value .<T> TgetArgument(String id) Fetches the parsed argument value may return null if the value parsed is not valid some cases of failed argument parsing may be like this one: an integer argument with min of 1 and max of 10, however the input was "one" or may be "-1" which is not a valid value .@Nullable StringgetRawArgument(int index) Fetches the raw argument from the input in the constructorThe raw arguments used in the context made by the command sender@Nullable Argument<?>getRequiredArgument(int index) Fetches the original required argument stated by the syntax executedintlength()The length of the args used in the raw context<T> voidparse()Parses the arguments into the used syntax this algorithm should provide good reasonable performanceintThe number of parsed args@NotNull StringThe raw arguments formatted using the command usedsender()Fetches the sender for this context@NotNull CommandSyntax<S>Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.mqzn.commands.base.context.Context
getLastIndex
-
Method Details
-
create
public static <S> CommandContext<S> create(@NotNull @NotNull CommandManager<?, S> manager, @NotNull @NotNull CommandSyntax<S> syntax, @NotNull @NotNull DelegateCommandContext<S> context) -
parse
Parses the arguments into the used syntax this algorithm should provide good reasonable performance- Specified by:
parsein interfaceContext<S>- Type Parameters:
T- the type of arguments that is being parsed- Throws:
ArgumentParseException
-
parsedArguments
public int parsedArguments()The number of parsed args- Specified by:
parsedArgumentsin interfaceContext<S>- Returns:
- the number of arguments parsed in the context
-
flags
The flags used in the command -
syntaxUsed
- Specified by:
syntaxUsedin interfaceContext<S>- Returns:
- The syntax used in the context of the command
-
length
public int length()The length of the args used in the raw context -
flagsUsed
public int flagsUsed()Fetches the number of flags used in the raw arguments -
sender
Fetches the sender for this context -
commandUsed
The command found and used in the context made by the command sender- Specified by:
commandUsedin interfaceContext<S>- Returns:
- the command used !
- See Also:
-
getRawArguments
The raw arguments used in the context made by the command sender- Specified by:
getRawArgumentsin interfaceContext<S>- Returns:
- The raw arguments
-
rawFormat
The raw arguments formatted using the command used -
getRawArgument
Fetches the raw argument from the input in the constructor- Specified by:
getRawArgumentin interfaceContext<S>- Parameters:
index- the index of the raw argument to fetch- Returns:
- the raw argument at a specific position
-
getArgument
Fetches the parsed argument value may return null if the value parsed is not valid some cases of failed argument parsing may be like this one: an integer argument with min of 1 and max of 10, however the input was "one" or may be "-1" which is not a valid value .- Specified by:
getArgumentin interfaceContext<S>- Type Parameters:
T- the type of arg value- Parameters:
id- the argument name/id- Returns:
- the parsed value of the argument
-
getArgument
@Nullable public <T> T getArgument(int index) Fetches the parsed argument value may return null if the value parsed is not valid some cases of failed argument parsing may be like this one: an integer argument with min of 1 and max of 10, however the input was "one" or may be "-1" which is not a valid value .- Specified by:
getArgumentin interfaceContext<S>- Type Parameters:
T- the type of arg value- Parameters:
index- the argument index/position- Returns:
- the parsed value of the argument
-
getRequiredArgument
Fetches the original required argument stated by the syntax executed- Specified by:
getRequiredArgumentin interfaceContext<S>- Parameters:
index- the index of the arg- Returns:
- the original required argument
-