Class ComponentArgumentType

java.lang.Object
net.kyori.adventure.platform.fabric.ComponentArgumentType
All Implemented Interfaces:
com.mojang.brigadier.arguments.ArgumentType<Component>

public final class ComponentArgumentType extends Object implements com.mojang.brigadier.arguments.ArgumentType<Component>
An argument that takes JSON-format text.

For this argument type to fully function, adventure-platform-fabric must also be present on the client. Clients without the mod will receive fallback types existing in the base game.

Since:
4.0.0
  • Method Details

    • component

      @Deprecated(forRemoval=true, since="5.1.0") @NotNull public static @NotNull ComponentArgumentType component()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use json() or miniMessage() instead.
      Get the argument type for component arguments.
      Returns:
      argument type instance
      Since:
      4.0.0
    • component

      @NotNull public static @NotNull Component component(@NotNull @NotNull com.mojang.brigadier.context.CommandContext<?> ctx, @NotNull @NotNull String key)
      Get the component from the provided context.
      Parameters:
      ctx - Context to get from
      key - argument key
      Returns:
      parsed component
      Since:
      4.0.0
    • json

      @NotNull public static @NotNull ComponentArgumentType json()
      Get the argument type for component arguments in JSON format.
      Returns:
      argument type instance
      Since:
      5.1.0
    • miniMessage

      @NotNull public static @NotNull ComponentArgumentType miniMessage()
      Get the argument type for component arguments in MiniMessage format.
      Returns:
      argument type instance
      Since:
      5.1.0
    • component

      @NotNull public static @NotNull ComponentArgumentType component(@NotNull @NotNull ComponentArgumentType.Format format)
      Get an argument type for component arguments.
      Parameters:
      format - the format to use when parsing component text
      Returns:
      an argument type
      Since:
      5.1.0
    • parse

      @NotNull public @NotNull Component parse(@NotNull @NotNull com.mojang.brigadier.StringReader reader) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Specified by:
      parse in interface com.mojang.brigadier.arguments.ArgumentType<Component>
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException
    • getExamples

      @NotNull public @NotNull Collection<String> getExamples()
      Specified by:
      getExamples in interface com.mojang.brigadier.arguments.ArgumentType<Component>
    • format

      @NotNull public @NotNull ComponentArgumentType.Format format()
      Get the format used for this argument.
      Returns:
      the format used for this argument
      Since:
      4.1.0