diff --git a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java index f74dcac..b149d64 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java +++ b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java @@ -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) {