From ac0e77de744a495bd854237249261162193fb7a7 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Fri, 5 May 2023 18:26:16 +0700 Subject: [PATCH] actually fix /say messages from command blocks --- .../chomens_bot/plugins/ChatPlugin.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) 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 f1a6968..0e6d68e 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 @@ -135,24 +135,25 @@ public class ChatPlugin extends Bot.Listener { final Component name = packet.getName(); final Component content = packet.getMessage(); + String translate = null; + + switch (type) { + case 1 -> translate = "chat.type.emote"; + case 4 -> translate = "chat.type.announcement"; + case 2 -> translate = "commands.message.display.incoming"; + } + + final Component component = Component.translatable( + translate, + name, + content + ); + + for (Listener listener : listeners) { + listener.systemMessageReceived(component); + } + for (ChatParser parser : chatParsers) { - String translate; - - switch (type) { - case 1 -> translate = "chat.type.emote"; - case 4 -> translate = "chat.type.announcement"; - case 2 -> translate = "commands.message.display.incoming"; - default -> { - continue; - } - } - - final Component component = Component.translatable( - translate, - name, - content - ); - final PlayerMessage parsed = parser.parse(component); if (parsed == null) continue; @@ -161,7 +162,6 @@ public class ChatPlugin extends Bot.Listener { for (Listener listener : listeners) { listener.playerMessageReceived(playerMessage); - listener.systemMessageReceived(component); } } } else {