From 9eeb3b6ec3f4812cfab57ae5d160472ebca87a9c Mon Sep 17 00:00:00 2001 From: "BT (calcastor/mame)" <43831917+calcastor@users.noreply.github.com> Date: Tue, 20 Aug 2024 00:07:35 -0700 Subject: [PATCH] Migrate method removed from PGM (#73) Signed-off-by: BT (calcastor/mame) <43831917+calcastor@users.noreply.github.com> --- .../community/chat/network/NetworkChatMessage.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/pgm/community/chat/network/NetworkChatMessage.java b/src/main/java/dev/pgm/community/chat/network/NetworkChatMessage.java index 1f77b695..8e9aa78e 100644 --- a/src/main/java/dev/pgm/community/chat/network/NetworkChatMessage.java +++ b/src/main/java/dev/pgm/community/chat/network/NetworkChatMessage.java @@ -5,6 +5,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; +import tc.oc.pgm.util.Audience; import tc.oc.pgm.util.channels.Channel; import tc.oc.pgm.util.event.ChannelMessageEvent; import tc.oc.pgm.util.named.NameStyle; @@ -18,9 +19,8 @@ public class NetworkChatMessage { private Channel channel; public NetworkChatMessage(ChannelMessageEvent event, String server) { - this.message = TextTranslations.toMinecraftGson(text(event.getMessage()), null); - this.sender = - TextTranslations.toMinecraftGson(player(event.getSender(), NameStyle.FANCY), null); + this.message = toMinecraftGson(text(event.getMessage())); + this.sender = toMinecraftGson(player(event.getSender(), NameStyle.FANCY)); this.channel = event.getChannel(); this.server = server; } @@ -40,4 +40,9 @@ public String getServer() { public Channel getChannel() { return channel; } + + private static String toMinecraftGson(Component component) { + Component translated = TextTranslations.translate(component, Audience.empty()); + return GsonComponentSerializer.colorDownsamplingGson().serialize(translated); + } }