From 9e22cdfea5c27f677db6666a2fdd5e7abc0aa64d Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 2 Nov 2024 15:29:47 +0700 Subject: [PATCH] feat: `getBotUsername` eval function --- .../evalFunctions/GetBotUsernameFunction.java | 15 +++++++++++++++ .../chayapak1/chomens_bot/plugins/EvalPlugin.java | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/main/java/me/chayapak1/chomens_bot/evalFunctions/GetBotUsernameFunction.java diff --git a/src/main/java/me/chayapak1/chomens_bot/evalFunctions/GetBotUsernameFunction.java b/src/main/java/me/chayapak1/chomens_bot/evalFunctions/GetBotUsernameFunction.java new file mode 100644 index 0000000..8a37a9c --- /dev/null +++ b/src/main/java/me/chayapak1/chomens_bot/evalFunctions/GetBotUsernameFunction.java @@ -0,0 +1,15 @@ +package me.chayapak1.chomens_bot.evalFunctions; + +import me.chayapak1.chomens_bot.Bot; +import me.chayapak1.chomens_bot.data.eval.EvalFunction; + +public class GetBotUsernameFunction extends EvalFunction { + public GetBotUsernameFunction (Bot bot) { + super("getBotUsername", bot); + } + + @Override + public Output execute(Object... args) { + return new Output(bot.username, false); + } +} diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/EvalPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/EvalPlugin.java index f483d1c..b011ca5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/EvalPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/EvalPlugin.java @@ -7,10 +7,7 @@ import io.socket.client.Socket; import me.chayapak1.chomens_bot.Bot; import me.chayapak1.chomens_bot.data.eval.EvalFunction; import me.chayapak1.chomens_bot.data.eval.EvalOutput; -import me.chayapak1.chomens_bot.evalFunctions.ChatFunction; -import me.chayapak1.chomens_bot.evalFunctions.CoreFunction; -import me.chayapak1.chomens_bot.evalFunctions.CorePlaceBlockFunction; -import me.chayapak1.chomens_bot.evalFunctions.GetPlayerListFunction; +import me.chayapak1.chomens_bot.evalFunctions.*; import java.util.ArrayList; import java.util.HashMap; @@ -38,6 +35,7 @@ public class EvalPlugin { functions.add(new CorePlaceBlockFunction(bot)); functions.add(new ChatFunction(bot)); functions.add(new GetPlayerListFunction(bot)); + functions.add(new GetBotUsernameFunction(bot)); try { socket = IO.socket(bot.config.eval.address);