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 284f88d..36a95cd 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 @@ -98,9 +98,12 @@ public class ChatPlugin extends Bot.Listener { if (id.equals(bot.commandSuggestion.id)) isCommandSuggestions = true; } + final String string = ComponentUtilities.stringify(component); + final String ansi = ComponentUtilities.stringifyAnsi(component); + for (Listener listener : listeners) { - if (!isCommandSuggestions) listener.systemMessageReceived(component); - listener.systemMessageReceived(component, isCommandSuggestions); + if (!isCommandSuggestions) listener.systemMessageReceived(component, string, ansi); + listener.systemMessageReceived(component, isCommandSuggestions, string, ansi); if (playerMessage != null) listener.playerMessageReceived(playerMessage); } @@ -157,9 +160,15 @@ public class ChatPlugin extends Bot.Listener { component = component.args(playerMessage.displayName, playerMessage.contents); } - listener.systemMessageReceived(component); + final String string = ComponentUtilities.stringify(component); + final String ansi = ComponentUtilities.stringifyAnsi(component); + + listener.systemMessageReceived(component, string, ansi); } else { - listener.systemMessageReceived(unsignedContent); + final String string = ComponentUtilities.stringify(unsignedContent); + final String ansi = ComponentUtilities.stringifyAnsi(unsignedContent); + + listener.systemMessageReceived(unsignedContent, string, ansi); } } } @@ -193,8 +202,11 @@ public class ChatPlugin extends Bot.Listener { translatableComponent = translatableComponent.args(name, content); } + final String string = ComponentUtilities.stringify(translatableComponent); + final String ansi = ComponentUtilities.stringifyAnsi(translatableComponent); + for (Listener listener : listeners) { - listener.systemMessageReceived(translatableComponent); + listener.systemMessageReceived(translatableComponent, string, ansi); } for (ChatParser parser : chatParsers) { @@ -213,10 +225,13 @@ public class ChatPlugin extends Bot.Listener { final PlayerMessage playerMessage = new PlayerMessage(parsedFromMessage.sender, packet.getName(), parsedFromMessage.contents); + final String string = ComponentUtilities.stringify(component); + final String ansi = ComponentUtilities.stringifyAnsi(component); + for (Listener listener : listeners) { listener.playerMessageReceived(playerMessage); - listener.systemMessageReceived(component); + listener.systemMessageReceived(component, string, ansi); } } } catch (Exception e) { @@ -347,7 +362,7 @@ public class ChatPlugin extends Bot.Listener { public static class Listener { public void playerMessageReceived (PlayerMessage message) {} - public void systemMessageReceived (Component component) {} - public void systemMessageReceived (Component component, boolean isCommandSuggestions) {} + public void systemMessageReceived (Component component, String string, String ansi) {} + public void systemMessageReceived (Component component, boolean isCommandSuggestions, String string, String ansi) {} } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSpyPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSpyPlugin.java index bb3849c..26240b8 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSpyPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSpyPlugin.java @@ -22,7 +22,7 @@ public class CommandSpyPlugin extends ChatPlugin.Listener { } @Override - public void systemMessageReceived(Component component) { + public void systemMessageReceived(Component component, String string, String ansi) { TextComponent textComponent; try { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java index f4913bd..1262e0c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandSuggestionPlugin.java @@ -20,7 +20,7 @@ public class CommandSuggestionPlugin extends ChatPlugin.Listener { } @Override - public void systemMessageReceived(Component component, boolean isCommandSuggestions) { + public void systemMessageReceived(Component component, boolean isCommandSuggestions, String string, String ansi) { if (!isCommandSuggestions) return; try { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java index 1899547..2405f38 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java @@ -63,10 +63,7 @@ public class DiscordPlugin { bot.chat.addListener(new ChatPlugin.Listener() { @Override - public void systemMessageReceived (Component component) { - final String string = ComponentUtilities.stringify(component); - final String ansi = ComponentUtilities.stringifyAnsi(component); - + public void systemMessageReceived (Component component, String string, String ansi) { if (string.length() > 2048) { sendMessage(CodeBlockUtilities.escape(string), channelId); } else { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java index e4f7fe8..60cf324 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java @@ -88,14 +88,11 @@ public class LoggerPlugin extends ChatPlugin.Listener { } @Override - public void systemMessageReceived(Component component) { - final String string = ComponentUtilities.stringify(component); - + public void systemMessageReceived(Component component, String string, String ansi) { if (logToConsole) { - final String ansi = ComponentUtilities.stringifyAnsi(component); - log(ansi, false, true); } + log(string, true, false); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java index 47b5a16..fe9ea94 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java @@ -47,9 +47,7 @@ public class SelfCarePlugin extends Bot.Listener { bot.chat.addListener(new ChatPlugin.Listener() { @Override - public void systemMessageReceived(Component component) { - final String string = ComponentUtilities.stringify(component); - + public void systemMessageReceived(Component component, String string, String ansi) { if (string.equals("Successfully enabled CommandSpy")) cspy = true; else if (string.equals("Successfully disabled CommandSpy")) cspy = false;