forked from ChomeNS/chipmunkmod
update chomens bot hashing
This commit is contained in:
parent
e578d45490
commit
701ad44325
1 changed files with 5 additions and 3 deletions
|
@ -67,19 +67,21 @@ public class BotValidationUtilities {
|
||||||
public static int chomens (String command) throws RuntimeException {
|
public static int chomens (String command) throws RuntimeException {
|
||||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens;
|
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens;
|
||||||
|
|
||||||
|
final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
final String prefix = info.prefix;
|
final String prefix = info.prefix;
|
||||||
final String key = info.key;
|
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?");
|
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
String[] arguments = command.split(" ");
|
||||||
|
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||||
String time = String.valueOf(System.currentTimeMillis() / 5_000);
|
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));
|
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||||
String stringHash = Hexadecimal.encode(hash).substring(0, 16);
|
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));
|
final String toSend = prefix + arguments[0] + " " + stringHash + " " + String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length));
|
||||||
|
|
||||||
CustomChat.INSTANCE.chat(toSend);
|
CustomChat.INSTANCE.chat(toSend);
|
||||||
|
|
Loading…
Reference in a new issue