diff --git a/.idea/compiler.xml b/.idea/compiler.xml index e766e0f..bcb93c4 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -3,14 +3,6 @@ - - - - - - - - diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/EvalPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/EvalPlugin.java index 2d34617..5be9cd1 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/EvalPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/EvalPlugin.java @@ -1,5 +1,7 @@ package land.chipmunk.chayapak.chomens_bot.plugins; +import com.google.gson.Gson; +import com.google.gson.JsonArray; import io.socket.client.IO; import io.socket.client.Socket; import land.chipmunk.chayapak.chomens_bot.Bot; @@ -24,6 +26,8 @@ public class EvalPlugin { public final List functions = new ArrayList<>(); + private final Gson gson = new Gson(); + public EvalPlugin (Bot bot) { functions.add(new CoreFunction(bot)); functions.add(new ChatFunction(bot)); @@ -37,7 +41,14 @@ public class EvalPlugin { socket.on(Socket.EVENT_CONNECT, (args) -> { connected = true; - socket.emit("setFunctions", "chat", "core"); + final JsonArray array = new JsonArray(); + + for (EvalFunction function : functions) array.add(function.name); + + socket.emit( + "setFunctions", + gson.toJson(array) + ); }); socket.on(Socket.EVENT_DISCONNECT, (args) -> connected = false); socket.on(Socket.EVENT_CONNECT_ERROR, (args) -> connected = false); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java index b5b0eb3..5b724a1 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/HashingPlugin.java @@ -28,7 +28,7 @@ public class HashingPlugin { final long time = System.currentTimeMillis() / 5_000; // mabe this will optimize it? - if (time == lastTime) return; + if (time <= lastTime) return; lastTime = time; final String normalHashKey = bot.config.keys.normalKey; @@ -40,7 +40,7 @@ public class HashingPlugin { .toString() .substring(0, 16); - final String ownerHashValue = (System.currentTimeMillis() / 5_000) + ownerHashKey; + final String ownerHashValue = time + ownerHashKey; ownerHash = Hashing.sha256() .hashString(ownerHashValue, StandardCharsets.UTF_8) .toString()