From 0ad227acae6ec1e5c652eab50767034f87b7258c Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 11 May 2023 13:16:16 +0700 Subject: [PATCH] update chomens chat parser --- .../systemChat/ChomeNSCustomChatParser.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java b/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java index 21ca493..370d661 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java +++ b/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java @@ -7,8 +7,10 @@ import land.chipmunk.chipmunkbot.data.chat.SystemChatParser; import land.chipmunk.chipmunkbot.util.ComponentUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; +import net.kyori.adventure.text.event.HoverEvent; import java.util.List; +import java.util.UUID; // ported from chomens sex bot public class ChomeNSCustomChatParser implements SystemChatParser { @@ -29,14 +31,22 @@ public class ChomeNSCustomChatParser implements SystemChatParser { final List args = message.args(); if (args.size() < 3 || (!message.key().equals("[%s] %s › %s") && !message.key().equals("%s %s › %s"))) return null; - final Component username = args.get(1); + final Component senderComponent = args.get(1); final Component contents = args.get(2); - final String stringUsername = ComponentUtilities.stringify(username); - MutablePlayerListEntry sender = client.playerList().getEntry(stringUsername); + MutablePlayerListEntry sender; + final HoverEvent hoverEvent = senderComponent.hoverEvent(); + if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) { + HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value(); + final UUID senderUUID = entityInfo.id(); + sender = client.playerList().getEntry(senderUUID); + } else { + final String stringUsername = ComponentUtilities.stringify(senderComponent); + sender = client.playerList().getEntry(stringUsername); + } if (sender == null) return null; - return new PlayerMessage(sender, contents, "minecraft:chat", username); + return new PlayerMessage(sender, contents, "minecraft:chat", senderComponent); } }