From dd5980cddf2c8eef9bdaee0959ffceebd9c5c070 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Mon, 24 Apr 2023 14:40:11 +0700 Subject: [PATCH] fix extras chat --- .idea/workspace.xml | 38 +++++++++---------- .../chomens_bot/plugins/ChatPlugin.java | 21 ++++++++++ 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 612e651..61eeed9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,7 +4,7 @@ - - @@ -481,7 +479,9 @@ - diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java index 878b2b2..762d643 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java @@ -160,6 +160,27 @@ public class ChatPlugin extends SessionAdapter { ); } } + } else { + final Component component = packet.getMessage(); + + PlayerMessage parsedFromMessage = null; + + for (ChatParser parser : chatParsers) { + parsedFromMessage = parser.parse(component); + if (parsedFromMessage != null) break; + } + + if (parsedFromMessage == null) return; + + final PlayerMessage playerMessage = new PlayerMessage(parsedFromMessage.sender(), packet.getName(), parsedFromMessage.contents()); + + for (ChatListener listener : listeners) { + listener.playerMessageReceived(playerMessage); + listener.systemMessageReceived( + ComponentUtilities.stringify(component), + component + ); + } } }