mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-17 08:05:25 +01:00
Optimise JsonMessage <-> Component
This commit is contained in:
parent
3b2d5fd7d0
commit
edbd244a07
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user