Interface GsonComponentSerializer
- All Superinterfaces:
net.kyori.adventure.util.Buildable<GsonComponentSerializer,GsonComponentSerializer.Builder>,net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,net.kyori.adventure.text.Component,String>
public interface GsonComponentSerializer extends net.kyori.adventure.text.serializer.ComponentSerializer<net.kyori.adventure.text.Component,net.kyori.adventure.text.Component,String>, net.kyori.adventure.util.Buildable<GsonComponentSerializer,GsonComponentSerializer.Builder>
A gson component serializer.
Use GsonComponentSerializer.Builder.downsampleColors() to support platforms
that do not understand hex colors that were introduced in Minecraft 1.16.
- Since:
- 4.0.0
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceGsonComponentSerializer.BuilderA builder forGsonComponentSerializer. -
Method Summary
Modifier and Type Method Description static GsonComponentSerializer.Builderbuilder()Creates a newGsonComponentSerializer.Builder.static @NonNull GsonComponentSerializercolorDownsamplingGson()Gets a component serializer for gson serialization and deserialization.@NonNull net.kyori.adventure.text.ComponentdeserializeFromTree(@NonNull com.google.gson.JsonElement input)Deserialize a component from input of typeJsonElement.static @NonNull GsonComponentSerializergson()Gets a component serializer for gson serialization and deserialization.@NonNull UnaryOperator<com.google.gson.GsonBuilder>populator()Gets the underlying gson populator.@NonNull com.google.gson.Gsonserializer()Gets the underlying gson serializer.@NonNull com.google.gson.JsonElementserializeToTree(@NonNull net.kyori.adventure.text.Component component)Deserialize a component to output of typeJsonElement.Methods inherited from interface net.kyori.adventure.util.Buildable
toBuilderMethods inherited from interface net.kyori.adventure.text.serializer.ComponentSerializer
deseializeOrNull, deserialize, deserializeOr, 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
@NonNull com.google.gson.Gson serializer()Gets the underlying gson serializer.- Returns:
- a gson serializer
- Since:
- 4.0.0
-
populator
@NonNull UnaryOperator<com.google.gson.GsonBuilder> populator()Gets the underlying gson populator.- Returns:
- a gson populator
- Since:
- 4.0.0
-
deserializeFromTree
@NonNull net.kyori.adventure.text.Component deserializeFromTree(@NonNull com.google.gson.JsonElement input)Deserialize a component from input of typeJsonElement.- Parameters:
input- the input- Returns:
- the component
- Since:
- 4.7.0
-
serializeToTree
@NonNull com.google.gson.JsonElement serializeToTree(@NonNull net.kyori.adventure.text.Component component)Deserialize a component to output of typeJsonElement.- Parameters:
component- the component- Returns:
- the json element
- Since:
- 4.7.0
-