Class MultipleOptionsArgument<TValue>

java.lang.Object
com.minecolonies.core.commands.arguments.MultipleOptionsArgument<TValue>
Type Parameters:
TValue - the generic type of the value that the parser should return (this must be shared across all options).
All Implemented Interfaces:
com.mojang.brigadier.arguments.ArgumentType<MultipleOptionsArgument.OptionContainer<TValue>>
Direct Known Subclasses:
ColonyIdArgument, MultiColonyIdArgument

public abstract class MultipleOptionsArgument<TValue> extends Object implements com.mojang.brigadier.arguments.ArgumentType<MultipleOptionsArgument.OptionContainer<TValue>>
Base argument class that can serve to handle multiple different option values.

You pass one more MultipleOptionsArgument.ArgumentOption instances into the constructor. The parser will then run over these options, in the specified order, and determine which option matches the argument value first.

Make sure the order can actually be respected in a logical way, with the outermost fallback option at the last position. For example:

  1. Match against a specific keyword
  2. Match against a known identifier (i.e. a number or UUID)
  3. Match against any other string value
If not a single option matches the argument value, the parser will automatically fail with the missing selector warning.
  • Constructor Details

  • Method Details

    • getValue

      protected static <TValue> TValue getValue(com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> context, String name) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Get the underlying value by running the resolver method on the chosen option parser.
      Type Parameters:
      TValue - the generic type of the option parser.
      Parameters:
      context - the command context.
      name - the name of the argument.
      Returns:
      the resolved value from the option.
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException - when any of the resolvers fail to resolve the finalized value.
    • parse

      public final MultipleOptionsArgument.OptionContainer<TValue> parse(com.mojang.brigadier.StringReader reader) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Specified by:
      parse in interface com.mojang.brigadier.arguments.ArgumentType<TValue>
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException
    • listSuggestions

      public <S> CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> listSuggestions(com.mojang.brigadier.context.CommandContext<S> context, com.mojang.brigadier.suggestion.SuggestionsBuilder builder)
      Specified by:
      listSuggestions in interface com.mojang.brigadier.arguments.ArgumentType<TValue>