Support FNFBoyfriendBot Validation

This commit is contained in:
Chayapak Supasakul 2024-10-21 10:22:53 +07:00
parent fef81cc15f
commit 951d4e35c1
4 changed files with 33 additions and 1 deletions

View file

@ -26,6 +26,7 @@ public class Configuration {
public BotInfo sbot = new BotInfo(":", null);
public BotInfo chipmunk = new BotInfo("'", null);
public ChomeNSBotInfo chomens = new ChomeNSBotInfo("*", null, null, null);
public BotInfo fnfboyfriend = new BotInfo("~", null);
public BotInfo kittycorp = new BotInfo("^", null);
public TestBotInfo testbot = new TestBotInfo("-", null);
}

View file

@ -18,10 +18,11 @@ public class ValidateCommand {
.then(literal("sbot").then(argument("command", greedyString()).executes(c -> sbot(getString(c, "command")))))
// .then(literal("chipmunk").then(argument("command", greedyString()).executes(c -> chipmunk(getString(c, "command")))))
.then(literal("chomens").then(argument("command", greedyString()).executes(c -> {
c.getSource().sendFeedback(Text.literal("Warning: Manual ChomeNS Bot validation is deprecated"));
c.getSource().sendFeedback(Text.literal("Warning: Manual ChomeNS Bot validation is deprecated. Please use the completions from typing the bot's prefix."));
return chomens(getString(c, "command"));
})))
.then(literal("fnfboyfriend").then(argument("command", greedyString()).executes(c -> fnfboyfriend(getString(c, "command")))))
.then(literal("kittycorp").then(argument("command", greedyString()).executes(c -> kittycorp(getString(c, "command")))))
);
}

View file

@ -115,6 +115,35 @@ public class BotValidationUtilities {
return Command.SINGLE_SUCCESS;
}
public static int fnfboyfriend (String command) {
try {
final String prefix = ChipmunkMod.CONFIG.bots.fnfboyfriend.prefix;
String[] arguments = command.split(" ");
long currentTime = System.currentTimeMillis() / 1000;
String input = currentTime + ChipmunkMod.CONFIG.bots.fnfboyfriend.key;
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : hash) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) hexString.append('0');
hexString.append(hex);
}
final String[] restArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
final String result = hexString.substring(0, 16);
Chat.sendChatMessage(prefix + arguments[0] + " " + result + " " + String.join(" ", restArguments));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return Command.SINGLE_SUCCESS;
}
public static int kittycorp (String command) throws RuntimeException {
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.kittycorp;
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();

View file

@ -15,6 +15,7 @@
"sbot": { "prefix": ":", "key": null },
"chipmunk": { "prefix": "'", "key": null },
"chomens": { "prefix": "*", "key": null, "authKey": null, "formatKey": null },
"fnfboyfriend": { "prefix": "~", "key": null },
"kittycorp": { "prefix": "^", "key": null },
"testbot": { "prefix": "-", "webhookUrl": null }
},