Interface CustomArgumentType<T,N>

Type Parameters:
T - custom type
N - type with an argument native to vanilla Minecraft (from ArgumentTypes)
All Superinterfaces:
com.mojang.brigadier.arguments.ArgumentType<T>
All Known Subinterfaces:
CustomArgumentType.Converted<T,N>

@Experimental @NullMarked public interface CustomArgumentType<T,N> extends com.mojang.brigadier.arguments.ArgumentType<T>
An argument type that wraps around a native-to-vanilla argument type. This argument receives special handling in that the native argument type will be sent to the client for possible client-side completions and syntax validation.

When implementing this class, you have to create your own parsing logic from a StringReader. If only want to convert from the native type (N) to the custom type (T), implement CustomArgumentType.Converted instead.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An argument type that wraps around a native-to-vanilla argument type.
  • Method Summary

    Modifier and Type
    Method
    Description
    Cannot be controlled by the server.
    com.mojang.brigadier.arguments.ArgumentType<N>
    Gets the native type that this argument uses, the type that is sent to the client.
    default <S> CompletableFuture<com.mojang.brigadier.suggestion.Suggestions>
    listSuggestions(com.mojang.brigadier.context.CommandContext<S> context, com.mojang.brigadier.suggestion.SuggestionsBuilder builder)
    Provides a list of suggestions to show to the client.
    parse(com.mojang.brigadier.StringReader reader)
    Parses the argument into the custom type (T).
  • Method Details

    • parse

      T parse(com.mojang.brigadier.StringReader reader) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Parses the argument into the custom type (T). Keep in mind that this parsing will be done on the server. This means that if you throw a CommandSyntaxException during parsing, this will only show up to the user after the user has executed the command not while they are still entering it.
      Specified by:
      parse in interface com.mojang.brigadier.arguments.ArgumentType<T>
      Parameters:
      reader - string reader input
      Returns:
      parsed value
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException - if an error occurs while parsing
    • getNativeType

      com.mojang.brigadier.arguments.ArgumentType<N> getNativeType()
      Gets the native type that this argument uses, the type that is sent to the client.
      Returns:
      native argument type
    • getExamples

      @NonExtendable default Collection<String> getExamples()
      Cannot be controlled by the server. Returned in cases where there are multiple arguments in the same node. This helps differentiate and tell the player what the possible inputs are.
      Specified by:
      getExamples in interface com.mojang.brigadier.arguments.ArgumentType<T>
      Returns:
      client set examples
    • listSuggestions

      default <S> CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> listSuggestions(com.mojang.brigadier.context.CommandContext<S> context, com.mojang.brigadier.suggestion.SuggestionsBuilder builder)
      Provides a list of suggestions to show to the client.
      Specified by:
      listSuggestions in interface com.mojang.brigadier.arguments.ArgumentType<T>
      Type Parameters:
      S - context type
      Parameters:
      context - command context
      builder - suggestion builder
      Returns:
      suggestions