refactor: have global Listener interface instead of creating one in each plugin

not sure how much this improves the code, readability and/or the performance but i hope they are better
This commit is contained in:
ChomeNS
2025-04-16 15:34:20 +07:00
parent 346c55c3d6
commit decd15a926
42 changed files with 429 additions and 441 deletions

View File

@@ -2,21 +2,21 @@ package me.chayapak1.chomens_bot.evalFunctions;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.eval.EvalFunction;
import me.chayapak1.chomens_bot.plugins.ChatPlugin;
import me.chayapak1.chomens_bot.data.listener.Listener;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
public class GetLatestChatMessageFunction extends EvalFunction implements ChatPlugin.Listener {
public class GetLatestChatMessageFunction extends EvalFunction implements Listener {
private String latestMessage = "";
public GetLatestChatMessageFunction (final Bot bot) {
super("getLatestChatMessage", bot);
bot.chat.addListener(this);
bot.listener.addListener(this);
}
@Override
public boolean systemMessageReceived (final Component component, final String string, final String ansi) {
public boolean onSystemMessageReceived (final Component component, final String string, final String ansi) {
latestMessage = GsonComponentSerializer.gson().serialize(component);
return true;