actually improve the systemMessageReceived thing
This commit is contained in:
parent
dd5980cddf
commit
287b02256e
4 changed files with 12 additions and 22 deletions
|
@ -81,9 +81,8 @@ public class ChatPlugin extends SessionAdapter {
|
||||||
PlayerMessage commandSpyMessage;
|
PlayerMessage commandSpyMessage;
|
||||||
commandSpyMessage = commandSpyParser.parse(component);
|
commandSpyMessage = commandSpyParser.parse(component);
|
||||||
|
|
||||||
final String message = ComponentUtilities.stringify(component);
|
|
||||||
for (ChatListener listener : listeners) {
|
for (ChatListener listener : listeners) {
|
||||||
listener.systemMessageReceived(message, component);
|
listener.systemMessageReceived(component);
|
||||||
if (playerMessage != null) listener.playerMessageReceived(playerMessage);
|
if (playerMessage != null) listener.playerMessageReceived(playerMessage);
|
||||||
if (commandSpyMessage != null) listener.commandSpyMessageReceived(commandSpyMessage);
|
if (commandSpyMessage != null) listener.commandSpyMessageReceived(commandSpyMessage);
|
||||||
}
|
}
|
||||||
|
@ -112,19 +111,13 @@ public class ChatPlugin extends SessionAdapter {
|
||||||
playerMessage.contents()
|
playerMessage.contents()
|
||||||
);
|
);
|
||||||
|
|
||||||
listener.systemMessageReceived(
|
listener.systemMessageReceived(component);
|
||||||
ComponentUtilities.stringify(component),
|
|
||||||
component
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
final Component unsignedContent = packet.getUnsignedContent();
|
final Component unsignedContent = packet.getUnsignedContent();
|
||||||
|
|
||||||
if (unsignedContent == null) return;
|
if (unsignedContent == null) return;
|
||||||
|
|
||||||
listener.systemMessageReceived(
|
listener.systemMessageReceived(unsignedContent);
|
||||||
ComponentUtilities.stringify(unsignedContent),
|
|
||||||
unsignedContent
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,10 +147,7 @@ public class ChatPlugin extends SessionAdapter {
|
||||||
|
|
||||||
for (ChatListener listener : listeners) {
|
for (ChatListener listener : listeners) {
|
||||||
listener.playerMessageReceived(playerMessage);
|
listener.playerMessageReceived(playerMessage);
|
||||||
listener.systemMessageReceived(
|
listener.systemMessageReceived(component);
|
||||||
ComponentUtilities.stringify(component),
|
|
||||||
component
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -176,10 +166,7 @@ public class ChatPlugin extends SessionAdapter {
|
||||||
|
|
||||||
for (ChatListener listener : listeners) {
|
for (ChatListener listener : listeners) {
|
||||||
listener.playerMessageReceived(playerMessage);
|
listener.playerMessageReceived(playerMessage);
|
||||||
listener.systemMessageReceived(
|
listener.systemMessageReceived(component);
|
||||||
ComponentUtilities.stringify(component),
|
|
||||||
component
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,6 +235,6 @@ public class ChatPlugin extends SessionAdapter {
|
||||||
public static class ChatListener {
|
public static class ChatListener {
|
||||||
public void playerMessageReceived (PlayerMessage message) {}
|
public void playerMessageReceived (PlayerMessage message) {}
|
||||||
public void commandSpyMessageReceived (PlayerMessage message) {}
|
public void commandSpyMessageReceived (PlayerMessage message) {}
|
||||||
public void systemMessageReceived (String message, Component component) {}
|
public void systemMessageReceived (Component component) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class DiscordPlugin {
|
||||||
|
|
||||||
bot.chat().addListener(new ChatPlugin.ChatListener() {
|
bot.chat().addListener(new ChatPlugin.ChatListener() {
|
||||||
@Override
|
@Override
|
||||||
public void systemMessageReceived (String ignoredMessage, Component component) {
|
public void systemMessageReceived (Component component) {
|
||||||
final String content = ComponentUtilities.stringifyAnsi(component);
|
final String content = ComponentUtilities.stringifyAnsi(component);
|
||||||
sendMessage(EscapeCodeBlock.escape(content.replace("\u001b[9", "\u001b[3")), channelId);
|
sendMessage(EscapeCodeBlock.escape(content.replace("\u001b[9", "\u001b[3")), channelId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class LoggerPlugin extends ChatPlugin.ChatListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void systemMessageReceived(String message, Component component) {
|
public void systemMessageReceived(Component component) {
|
||||||
final String ansiMessage = ComponentUtilities.stringifyAnsi(component);
|
final String ansiMessage = ComponentUtilities.stringifyAnsi(component);
|
||||||
log(ansiMessage);
|
log(ansiMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import com.github.steveice10.packetlib.packet.PacketProtocol;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Configuration;
|
import land.chipmunk.chayapak.chomens_bot.Configuration;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
@ -52,7 +53,9 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||||
|
|
||||||
bot.chat().addListener(new ChatPlugin.ChatListener() {
|
bot.chat().addListener(new ChatPlugin.ChatListener() {
|
||||||
@Override
|
@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;
|
if (message.equals("Successfully enabled CommandSpy")) cspy = true;
|
||||||
else if (message.equals("Successfully disabled CommandSpy")) cspy = false;
|
else if (message.equals("Successfully disabled CommandSpy")) cspy = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue