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 762d643..08abb2e 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 @@ -81,9 +81,8 @@ public class ChatPlugin extends SessionAdapter { PlayerMessage commandSpyMessage; commandSpyMessage = commandSpyParser.parse(component); - final String message = ComponentUtilities.stringify(component); for (ChatListener listener : listeners) { - listener.systemMessageReceived(message, component); + listener.systemMessageReceived(component); if (playerMessage != null) listener.playerMessageReceived(playerMessage); if (commandSpyMessage != null) listener.commandSpyMessageReceived(commandSpyMessage); } @@ -112,19 +111,13 @@ public class ChatPlugin extends SessionAdapter { playerMessage.contents() ); - listener.systemMessageReceived( - ComponentUtilities.stringify(component), - component - ); + listener.systemMessageReceived(component); } else { final Component unsignedContent = packet.getUnsignedContent(); if (unsignedContent == null) return; - listener.systemMessageReceived( - ComponentUtilities.stringify(unsignedContent), - unsignedContent - ); + listener.systemMessageReceived(unsignedContent); } } } @@ -154,10 +147,7 @@ public class ChatPlugin extends SessionAdapter { for (ChatListener listener : listeners) { listener.playerMessageReceived(playerMessage); - listener.systemMessageReceived( - ComponentUtilities.stringify(component), - component - ); + listener.systemMessageReceived(component); } } } else { @@ -176,10 +166,7 @@ public class ChatPlugin extends SessionAdapter { for (ChatListener listener : listeners) { listener.playerMessageReceived(playerMessage); - listener.systemMessageReceived( - ComponentUtilities.stringify(component), - component - ); + listener.systemMessageReceived(component); } } } @@ -248,6 +235,6 @@ public class ChatPlugin extends SessionAdapter { public static class ChatListener { public void playerMessageReceived (PlayerMessage message) {} public void commandSpyMessageReceived (PlayerMessage message) {} - public void systemMessageReceived (String message, Component component) {} + public void systemMessageReceived (Component component) {} } } 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 4f55466..8d78117 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 @@ -58,7 +58,7 @@ public class DiscordPlugin { bot.chat().addListener(new ChatPlugin.ChatListener() { @Override - public void systemMessageReceived (String ignoredMessage, Component component) { + public void systemMessageReceived (Component component) { final String content = ComponentUtilities.stringifyAnsi(component); sendMessage(EscapeCodeBlock.escape(content.replace("\u001b[9", "\u001b[3")), channelId); } 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 45fa5e5..c8c2c05 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 @@ -82,7 +82,7 @@ public class LoggerPlugin extends ChatPlugin.ChatListener { } @Override - public void systemMessageReceived(String message, Component component) { + public void systemMessageReceived(Component component) { final String ansiMessage = ComponentUtilities.stringifyAnsi(component); log(ansiMessage); } 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 1322ff1..3cd5f8b 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 @@ -19,6 +19,7 @@ import com.github.steveice10.packetlib.packet.PacketProtocol; import com.nukkitx.math.vector.Vector3i; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Configuration; +import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; @@ -52,7 +53,9 @@ public class SelfCarePlugin extends SessionAdapter { bot.chat().addListener(new ChatPlugin.ChatListener() { @Override - public void systemMessageReceived(String message, Component component) { + public void systemMessageReceived(Component component) { + final String message = ComponentUtilities.stringify(component); + if (message.equals("Successfully enabled CommandSpy")) cspy = true; else if (message.equals("Successfully disabled CommandSpy")) cspy = false;