mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-08 08:21:50 +01:00
Make JsonMessage a ComponentLike
This commit is contained in:
parent
838c95828d
commit
9fca53a8d3
@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -17,7 +18,7 @@ import java.util.Objects;
|
||||
* @see <a href="https://wiki.vg/Chat">Chat Format</a>
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class JsonMessage {
|
||||
public abstract class JsonMessage implements ComponentLike {
|
||||
|
||||
// true if the compiled string is up-to-date, false otherwise
|
||||
private boolean updated;
|
||||
@ -52,11 +53,8 @@ public abstract class JsonMessage {
|
||||
return getTextMessage(getJsonObject()).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this JSON message as an Adventure Component.
|
||||
* @return the component
|
||||
*/
|
||||
public Component asComponent() {
|
||||
@Override
|
||||
public @NotNull Component asComponent() {
|
||||
return GsonComponentSerializer.gson().deserialize(this.toString());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user