Interface GsonComponentSerializer
- All Superinterfaces:
ComponentDecoder<String, Component>, ComponentEncoder<Component, String>, ComponentSerializer<Component, Component, String>, JSONComponentSerializer
A gson component serializer.
This is a specific implementation of JSONComponentSerializer for the Gson library.
Libraries that want to remain unopinionated should work with that interface instead.
Use colorDownsamplingGson() to support platforms
that do not understand hex colors that were introduced in Minecraft 1.16.
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder forGsonComponentSerializer.static interfaceAGsonComponentSerializerservice provider. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a newGsonComponentSerializer.Builder.static GsonComponentSerializerGets a component serializer for gson serialization and deserialization.deserializeFromTree(com.google.gson.JsonElement input) Deserialize a component from input of typeJsonElement.static GsonComponentSerializergson()Gets a component serializer for gson serialization and deserialization.UnaryOperator<com.google.gson.GsonBuilder> Gets the underlying gson populator.com.google.gson.GsonGets the underlying gson serializer.com.google.gson.JsonElementserializeToTree(Component component) Deserialize a component to output of typeJsonElement.Creates a new builder from this serializer.Methods inherited from interface ComponentSerializer
deserialize, deserializeOr, deserializeOrNull, serialize, serializeOr, serializeOrNull
-
Method Details
-
gson
Gets a component serializer for gson serialization and deserialization.- Returns:
- a gson component serializer
- Since:
- 4.0.0
-
colorDownsamplingGson
Gets a component serializer for gson serialization and deserialization.Hex colors are coerced to the nearest named color, and legacy hover events are emitted for action
HoverEvent.Action.SHOW_TEXT.- Returns:
- a gson component serializer
- Since:
- 4.0.0
-
builder
Creates a newGsonComponentSerializer.Builder.- Returns:
- a builder
- Since:
- 4.0.0
-
serializer
com.google.gson.Gson serializer()Gets the underlying gson serializer.- Returns:
- a gson serializer
- Since:
- 4.0.0
-
populator
UnaryOperator<com.google.gson.GsonBuilder> populator()Gets the underlying gson populator.- Returns:
- a gson populator
- Since:
- 4.0.0
-
deserializeFromTree
Deserialize a component from input of typeJsonElement.- Parameters:
input- the input- Returns:
- the component
- Since:
- 4.7.0
-
serializeToTree
Deserialize a component to output of typeJsonElement.- Parameters:
component- the component- Returns:
- the json element
- Since:
- 4.7.0
-
toBuilder
GsonComponentSerializer.Builder toBuilder()Creates a new builder from this serializer.- Returns:
- the builder
- Since:
- 4.0.0
-