This commit is contained in:
Chayapak 2023-08-02 13:21:16 +07:00
parent da7c775ed3
commit 95d193d11c
6 changed files with 29 additions and 22 deletions

View file

@ -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) {}
}
}

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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);
}
}

View file

@ -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;