Skip to content

Commit

Permalink
Migrate method removed from PGM (#73)
Browse files Browse the repository at this point in the history
Signed-off-by: BT (calcastor/mame) <[email protected]>
  • Loading branch information
calcastor authored Aug 20, 2024
1 parent 0d87b4a commit 9eeb3b6
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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);
}
}

0 comments on commit 9eeb3b6

Please sign in to comment.