Class FlagArgument.FlagArgumentParser<C>

java.lang.Object
cloud.commandframework.arguments.compound.FlagArgument.FlagArgumentParser<C>
All Implemented Interfaces:
ArgumentParser<C,Object>
Enclosing class:
FlagArgument<C>

@API(status=STABLE) public static final class FlagArgument.FlagArgumentParser<C> extends Object implements ArgumentParser<C,Object>
  • Method Details

    • parse

      public @NonNull ArgumentParseResult<@NonNull Object> parse(@NonNull CommandContext<@NonNull C> commandContext, @NonNull Queue<@NonNull String> inputQueue)
      Description copied from interface: ArgumentParser
      Parse command input into a command result.

      This method may be called when a command chain is being parsed for execution (using CommandManager.executeCommand(Object, String)) or when a command is being parsed to provide context for suggestions (using CommandManager.suggest(Object, String)). It is possible to use CommandContext.isSuggestions()} to see what the purpose of the parsing is. Particular care should be taken when parsing for suggestions, as the parsing method is then likely to be called once for every character written by the command sender.

      This method should never throw any exceptions under normal circumstances. Instead, if the parsing for some reason cannot be done successfully ArgumentParseResult.failure(Throwable) should be returned. This then wraps any exception that should be forwarded to the command sender.

      The parser is assumed to be completely stateless and should not store any information about the command sender or the command context. Instead, information should be stored in the CommandContext.

      Specified by:
      parse in interface ArgumentParser<C,Object>
      Parameters:
      commandContext - Command context
      inputQueue - The queue of arguments
      Returns:
      Parsed command result
    • parseCurrentFlag

      public @NonNull Optional<String> parseCurrentFlag(@NonNull CommandContext<@NonNull C> commandContext, @NonNull Queue<@NonNull String> inputQueue)
      Parse command input to figure out what flag is currently being typed at the end of the input queue. If no flag value is being inputted, returns Optional.empty().

      Will consume all but the last element from the input queue.
      Parameters:
      commandContext - Command context
      inputQueue - The input queue of arguments
      Returns:
      current flag being typed, or empty() if none is
    • suggestions

      public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input)
      Description copied from interface: ArgumentParser
      Get a list of suggested arguments that would be correctly parsed by this parser

      This method is likely to be called for every character provided by the sender and so it may be necessary to cache results locally to prevent unnecessary computations

      Specified by:
      suggestions in interface ArgumentParser<C,Object>
      Parameters:
      commandContext - Command context
      input - Input string
      Returns:
      List of suggestions