remove eval functions

This commit is contained in:
Chayapak 2023-09-25 18:32:42 +07:00
parent 65c79f9d9b
commit a9b616590d
5 changed files with 0 additions and 117 deletions

View file

@ -1,18 +0,0 @@
package land.chipmunk.chayapak.chomens_bot.evalFunctions;
import land.chipmunk.chayapak.chomens_bot.Bot;
public class ChatFunction extends EvalFunction {
public ChatFunction (Bot bot) {
super("chat", bot);
}
@Override
public Output execute(Object... args) {
final String message = (String) args[0];
bot.chat.send(message);
return null;
}
}

View file

@ -1,18 +0,0 @@
package land.chipmunk.chayapak.chomens_bot.evalFunctions;
import land.chipmunk.chayapak.chomens_bot.Bot;
public class CoreFunction extends EvalFunction {
public CoreFunction (Bot bot) {
super("core", bot);
}
@Override
public Output execute(Object... args) {
final String command = (String) args[0];
bot.core.run(command);
return null;
}
}

View file

@ -1,18 +0,0 @@
package land.chipmunk.chayapak.chomens_bot.evalFunctions;
import land.chipmunk.chayapak.chomens_bot.Bot;
public class CorePlaceBlockFunction extends EvalFunction {
public CorePlaceBlockFunction (Bot bot) {
super("corePlaceBlock", bot);
}
@Override
public Output execute(Object... args) {
final String command = (String) args[0];
bot.core.runPlaceBlock(command);
return null;
}
}

View file

@ -1,29 +0,0 @@
package land.chipmunk.chayapak.chomens_bot.evalFunctions;
import land.chipmunk.chayapak.chomens_bot.Bot;
public class EvalFunction {
public final String name;
protected final Bot bot;
public EvalFunction (
String name,
Bot bot
) {
this.name = name;
this.bot = bot;
}
public Output execute (Object ...args) { return null; }
public static class Output {
public final String message;
public final boolean parseJSON;
public Output (String message, boolean parseJSON) {
this.message = message;
this.parseJSON = parseJSON;
}
}
}

View file

@ -1,34 +0,0 @@
package land.chipmunk.chayapak.chomens_bot.evalFunctions;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerEntry;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import java.util.List;
public class GetPlayerListFunction extends EvalFunction {
public GetPlayerListFunction(Bot bot) {
super("getPlayerList", bot);
}
@Override
public Output execute(Object... args) {
final List<PlayerEntry> list = bot.players.list;
final JsonArray array = new JsonArray();
for (PlayerEntry entry : list) {
final JsonObject object = new JsonObject();
object.addProperty("uuid", entry.profile.getIdAsString());
object.addProperty("username", entry.profile.getName());
if (entry.displayName != null) object.addProperty("displayName", GsonComponentSerializer.gson().serialize(entry.displayName));
array.add(object);
}
return new Output(array.toString(), true);
}
}