Optimise JsonMessage <-> Component

This commit is contained in:
Kieran Wallbanks 2021-03-04 13:20:28 +00:00
parent 3b2d5fd7d0
commit edbd244a07

View File

@ -55,11 +55,11 @@ public abstract class JsonMessage implements ComponentLike {
@Override
public @NotNull Component asComponent() {
return GsonComponentSerializer.gson().deserialize(this.toString());
return GsonComponentSerializer.gson().serializer().fromJson(this.getJsonObject(), Component.class);
}
public static @NotNull JsonMessage fromComponent(@NotNull Component component) {
return new RawJsonMessage(GsonComponentSerializer.gson().serialize(component));
return new RawJsonMessage(GsonComponentSerializer.gson().serializer().toJsonTree(component).getAsJsonObject());
}
/**