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