From 285513a3327b187006a89b376e2019278537f473 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+chomens@users.noreply.github.com> Date: Sun, 10 Nov 2024 14:47:09 +0700 Subject: [PATCH] fix: nbot hashing finaly fix 2024/11/10 14:30-40 or something --- .../chipmunk/chipmunkmod/util/BotValidationUtilities.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java index ceca101..a0debb1 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java +++ b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java @@ -147,7 +147,6 @@ public class BotValidationUtilities { return Command.SINGLE_SUCCESS; } - // !!! broken (for now) public static int nbot (String command) throws RuntimeException { final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.nbot; @@ -169,9 +168,9 @@ public class BotValidationUtilities { byte[] hash = md.digest(); - long bigInt = ByteBuffer.wrap(new byte[] {0, 0, hash[0], hash[1], hash[2], hash[3], hash[4], hash[5]}).getLong(); - - String stringHash = Long.toUnsignedString(bigInt, 36).substring(0, 7); + ByteBuffer buffer = ByteBuffer.wrap(hash, 0, 5); + int bigInt = Math.abs(buffer.getInt()); + String stringHash = Integer.toString(bigInt, 36); final String[] restArguments = Arrays.copyOfRange(arguments, 1, arguments.length);