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 @@
-
+
@@ -98,20 +98,6 @@
1680245437032
-
- 1681547771112
-
-
-
- 1681547771112
-
-
- 1681558738607
-
-
-
- 1681558738607
-
1681607369880
@@ -441,7 +427,21 @@
1682320575423
-
+
+ 1682321283783
+
+
+
+ 1682321283783
+
+
+ 1682321509974
+
+
+
+ 1682321509974
+
+
@@ -456,8 +456,6 @@
-
-
@@ -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
+ );
+ }
}
}