From 701ad443257b67b7977590011f8dcb909251676a Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:07:40 +0700 Subject: [PATCH] update chomens bot hashing --- .../chipmunk/chipmunkmod/util/BotValidationUtilities.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java index d300d1b..4467000 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java +++ b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java @@ -67,19 +67,21 @@ public class BotValidationUtilities { public static int chomens (String command) throws RuntimeException { final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens; + final MinecraftClient client = MinecraftClient.getInstance(); + final String prefix = info.prefix; final String key = info.key; if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?"); try { + String[] arguments = command.split(" "); + MessageDigest md = MessageDigest.getInstance("SHA-256"); String time = String.valueOf(System.currentTimeMillis() / 5_000); - String input = time + key; + String input = client.player.getUuidAsString() + arguments[0] + time + key; byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8)); String stringHash = Hexadecimal.encode(hash).substring(0, 16); - String[] arguments = command.split(" "); - final String toSend = prefix + arguments[0] + " " + stringHash + " " + String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length)); CustomChat.INSTANCE.chat(toSend);