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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user