forked from ChomeNS/chipmunkmod
section signs chomens bot validation
This commit is contained in:
parent
6a26456bc1
commit
198ec68b43
1 changed files with 22 additions and 1 deletions
|
@ -6,6 +6,7 @@ import land.chipmunk.chipmunkmod.Configuration;
|
|||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -69,6 +70,8 @@ public class BotValidationUtilities {
|
|||
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
final ClientPlayerEntity player = client.player;
|
||||
|
||||
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?");
|
||||
|
@ -82,7 +85,25 @@ public class BotValidationUtilities {
|
|||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
String stringHash = Hexadecimal.encode(hash).substring(0, 16);
|
||||
|
||||
final String toSend = prefix + arguments[0] + " " + stringHash + " " + String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length));
|
||||
final boolean shouldSectionSign = CustomChat.INSTANCE.enabled && player.hasPermissionLevel(2) && player.isCreative();
|
||||
|
||||
if (shouldSectionSign) {
|
||||
stringHash = String.join("",
|
||||
Arrays.stream(stringHash.split(""))
|
||||
.map((letter) -> "§" + letter)
|
||||
.toArray(String[]::new)
|
||||
);
|
||||
}
|
||||
|
||||
final String[] restArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
|
||||
|
||||
final String toSend = prefix +
|
||||
arguments[0] +
|
||||
" " +
|
||||
stringHash +
|
||||
(shouldSectionSign ? "§r" : "") +
|
||||
" " +
|
||||
String.join(" ", restArguments);
|
||||
|
||||
CustomChat.INSTANCE.chat(toSend);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
|
Loading…
Reference in a new issue