refactor: make listeners an interface

(except the one in Bot, which extends MCProtocolLib's SessionAdaptor, not sure how exactly make them complement)
This commit is contained in:
ChomeNS
2025-03-23 14:18:55 +07:00
parent 60356a5eea
commit 0a8efe0189
30 changed files with 261 additions and 311 deletions

View File

@@ -13,7 +13,7 @@ import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
public class QueryPlugin extends Bot.Listener {
public class QueryPlugin extends Bot.Listener implements ChatPlugin.Listener {
private final Bot bot;
public long nextTransactionId = 0;
@@ -24,16 +24,11 @@ public class QueryPlugin extends Bot.Listener {
this.bot = bot;
bot.addListener(this);
bot.chat.addListener(new ChatPlugin.Listener() {
@Override
public boolean systemMessageReceived(Component component, String string, String ansi) {
return QueryPlugin.this.systemMessageReceived(component);
}
});
bot.chat.addListener(this);
}
private boolean systemMessageReceived (Component component) {
@Override
public boolean systemMessageReceived (Component component, String string, String ansi) {
if (!(component instanceof TextComponent textComponent)) return true;
try {