Interface GsonComponentSerializer
-
- All Superinterfaces:
Buildable<GsonComponentSerializer,GsonComponentSerializer.Builder>
,ComponentEncoder<Component,java.lang.String>
,ComponentSerializer<Component,Component,java.lang.String>
,JSONComponentSerializer
public interface GsonComponentSerializer extends JSONComponentSerializer, Buildable<GsonComponentSerializer,GsonComponentSerializer.Builder>
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
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 interface
GsonComponentSerializer.Builder
A builder forGsonComponentSerializer
.static interface
GsonComponentSerializer.Provider
AGsonComponentSerializer
service provider.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static GsonComponentSerializer.Builder
builder()
Creates a newGsonComponentSerializer.Builder
.static @NotNull GsonComponentSerializer
colorDownsamplingGson()
Gets a component serializer for gson serialization and deserialization.@NotNull Component
deserializeFromTree(@NotNull com.google.gson.JsonElement input)
Deserialize a component from input of typeJsonElement
.static @NotNull GsonComponentSerializer
gson()
Gets a component serializer for gson serialization and deserialization.@NotNull java.util.function.UnaryOperator<com.google.gson.GsonBuilder>
populator()
Gets the underlying gson populator.@NotNull com.google.gson.Gson
serializer()
Gets the underlying gson serializer.@NotNull com.google.gson.JsonElement
serializeToTree(@NotNull Component component)
Deserialize a component to output of typeJsonElement
.-
Methods inherited from interface net.kyori.adventure.text.serializer.ComponentSerializer
deseializeOrNull, deserialize, deserializeOr, deserializeOrNull, serialize, serializeOr, serializeOrNull
-
-
-
-
Method Detail
-
gson
@NotNull static @NotNull GsonComponentSerializer gson()
Gets a component serializer for gson serialization and deserialization.- Returns:
- a gson component serializer
- Since:
- 4.0.0
-
colorDownsamplingGson
@NotNull static @NotNull GsonComponentSerializer 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
static GsonComponentSerializer.Builder builder()
Creates a newGsonComponentSerializer.Builder
.- Returns:
- a builder
- Since:
- 4.0.0
-
serializer
@NotNull @NotNull com.google.gson.Gson serializer()
Gets the underlying gson serializer.- Returns:
- a gson serializer
- Since:
- 4.0.0
-
populator
@NotNull @NotNull java.util.function.UnaryOperator<com.google.gson.GsonBuilder> populator()
Gets the underlying gson populator.- Returns:
- a gson populator
- Since:
- 4.0.0
-
deserializeFromTree
@NotNull @NotNull Component deserializeFromTree(@NotNull @NotNull com.google.gson.JsonElement input)
Deserialize a component from input of typeJsonElement
.- Parameters:
input
- the input- Returns:
- the component
- Since:
- 4.7.0
-
serializeToTree
@NotNull @NotNull com.google.gson.JsonElement serializeToTree(@NotNull @NotNull Component component)
Deserialize a component to output of typeJsonElement
.- Parameters:
component
- the component- Returns:
- the json element
- Since:
- 4.7.0
-
-