Class ComponentArgumentType
java.lang.Object
net.kyori.adventure.platform.modcommon.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 function, adventure-platform must also be present on the client. In the Fabric environment, clients without adventure-platform will receive fallback argument types with limited functionality, in other environments clients without the mod are expected to error on join.
- Since:
- 6.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Supported text formats for registering components. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Component
Get the component from the provided context.static @NotNull ComponentArgumentType
component
(@NotNull ComponentArgumentType.Format format) Get an argument type for component arguments.@NotNull ComponentArgumentType.Format
format()
Get the format used for this argument.@NotNull Collection
<String> static @NotNull ComponentArgumentType
json()
Get the argument type for component arguments in JSON format.static @NotNull ComponentArgumentType
Get the argument type for component arguments in MiniMessage format.@NotNull Component
parse
(@NotNull com.mojang.brigadier.StringReader reader) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.mojang.brigadier.arguments.ArgumentType
listSuggestions
-
Method Details
-
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 fromkey
- argument key- Returns:
- parsed component
- Since:
- 6.0.0
-
json
Get the argument type for component arguments in JSON format.- Returns:
- argument type instance
- Since:
- 6.0.0
-
miniMessage
Get the argument type for component arguments in MiniMessage format.- Returns:
- argument type instance
- Since:
- 6.0.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:
- 6.0.0
-
parse
@NotNull public @NotNull Component parse(@NotNull @NotNull com.mojang.brigadier.StringReader reader) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Specified by:
parse
in interfacecom.mojang.brigadier.arguments.ArgumentType<Component>
- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
getExamples
- Specified by:
getExamples
in interfacecom.mojang.brigadier.arguments.ArgumentType<Component>
-
format
Get the format used for this argument.- Returns:
- the format used for this argument
- Since:
- 6.0.0
-