From 2dec676bdcc6e37ffb4e898ba7515a3682ec5fa2 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 1 Apr 2023 13:29:08 +0700 Subject: [PATCH] fix chat.type.text after ages --- .../chatParsers/MinecraftChatParser.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/MinecraftChatParser.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/MinecraftChatParser.java index d894d58..e8df4a5 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/MinecraftChatParser.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/MinecraftChatParser.java @@ -1,19 +1,16 @@ package land.chipmunk.chayapak.chomens_bot.chatParsers; -import com.github.steveice10.mc.auth.data.GameProfile; -import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; +import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.chatParsers.data.ChatParser; import land.chipmunk.chayapak.chomens_bot.chatParsers.data.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.chatParsers.data.PlayerMessage; -import land.chipmunk.chayapak.chomens_bot.Bot; +import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; -import net.kyori.adventure.text.event.HoverEvent; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; public class MinecraftChatParser implements ChatParser { private final Bot bot; @@ -48,14 +45,10 @@ public class MinecraftChatParser implements ChatParser { final Component senderComponent = args.get(0); final Component contents = args.get(1); - // try to find the sender then make it a player list entry - final HoverEvent hoverEvent = senderComponent.hoverEvent(); - if (hoverEvent == null || !hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) return null; - HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value(); - final UUID senderUUID = entityInfo.id(); + final String stringUsername = ComponentUtilities.stringify(senderComponent); + MutablePlayerListEntry sender = bot.players().getEntry(stringUsername); - MutablePlayerListEntry sender = bot.players().getEntry(senderUUID); - if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(senderUUID, null), GameMode.SURVIVAL, 0, entityInfo.name(), 0L, null, new byte[0]); + if (sender == null) return null; parameters.put("sender", senderComponent); parameters.put("contents", contents);