diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java index a0d3991..3b73dc2 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java +++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java @@ -86,7 +86,18 @@ public class ChatPlugin extends SessionAdapter { public void packetReceived (Session session, ClientboundPlayerChatPacket packet) { final MutablePlayerListEntry sender = client.playerList().getEntry(packet.getSender()); if (sender == null) return; - final PlayerMessage playerMessage = new PlayerMessage(sender, packet.getUnsignedContent(), "minecraft:chat", packet.getName()); // TODO: Fix chatType + + PlayerMessage parsedFromMessage = null; + final Component component = packet.getUnsignedContent(); + + for (SystemChatParser parser : systemChatParsers) { + parsedFromMessage = parser.parse(component); + if (parsedFromMessage != null) break; + } + + if (parsedFromMessage == null) return; + + final PlayerMessage playerMessage = new PlayerMessage(sender, parsedFromMessage.contents(), "minecraft:chat", packet.getName()); // TODO: Fix chatType for (Listener listener : this.listeners) { listener.playerMessageReceived(playerMessage);