Skip to content

Commit

Permalink
fix: ChatBypass starting
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Oct 19, 2024
1 parent efe61f4 commit d51b2d5
Showing 1 changed file with 40 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,86 +15,71 @@ import net.ccbluex.liquidbounce.value.IntegerValue
import net.ccbluex.liquidbounce.value.ListValue
import net.minecraft.network.play.client.C01PacketChatMessage

object ChatBypass : Module("ChatBypass", Category.EXPLOIT, canBeEnabled = false, hideModule = false) {
object ChatBypass : Module("ChatBypass", Category.EXPLOIT, hideModule = false) {

private val modeValue by ListValue("Mode", arrayOf("Null", "RandomChar", "Unicode", "RandomUnicode", "ToPinyin"), "Null")
private val chanceValue by FloatValue("Chance", 0.2F, 0F..0.5F) { modeValue != "Unicode" }

private val minUnicodeValue: IntegerValue = object : IntegerValue("MinUnicode", 1000, 0..100000) {
override fun onChanged(oldValue: Int, newValue: Int) {
if (newValue >= maxUnicodeValue.get()) {
set(oldValue)
}
}
}

private val maxUnicodeValue: IntegerValue = object : IntegerValue("MaxUnicode", 20000, 0..100000) {
override fun onChanged(oldValue: Int, newValue: Int) {
if (newValue <= minUnicodeValue.get()) {
set(oldValue)
}
}
}

@EventTarget
fun onPacket(event: PacketEvent) {
if (event.packet is C01PacketChatMessage) {
val packet = event.packet
val truncatedMessage = packet.message.take(100)
if (truncatedMessage.startsWith("/")) return

val newMessage = processMessage(truncatedMessage)
packet.message = newMessage
}
}

private fun processMessage(message: String): String {
val chance = Math.random()
val mode = modeValue.lowercase()

return when (mode) {
"null" -> processNullMode(message, chance)
"randomchar" -> processRandomCharMode(message, chance)
"unicode" -> processUnicodeMode(message)
"randomunicode" -> processRandomUnicodeMode(message, chance)
else -> message
}
}

private fun processNullMode(message: String, chance: Double): String {
val sb = StringBuilder()
for (char in message.toCharArray()) {
sb.append(char)
if (chance < chanceValue) {
sb.append("\uF8FF")
val message = packet.message
if (message.startsWith("/")) return
when (modeValue.lowercase()) {
else -> {
val sb = StringBuilder()
for (char in message.toCharArray()) {
when (modeValue.lowercase()) {
"null" -> {
sb.append(char)
if (Math.random() < chanceValue) {
sb.append("\uF8FF")
}
}
"randomchar" -> {
sb.append(char)
if (Math.random() < chanceValue) {
sb.append((RandomUtils.nextInt(minUnicodeValue.get(), maxUnicodeValue.get())).toChar())
}
}
"unicode" -> {
if (char.code in 33..128) {
sb.append(Character.toChars(char.code + 65248))
} else {
sb.append(char)
}
}
"randomunicode" -> {
if ((Math.random() < chanceValue) && (char.code in 33..128)) {
sb.append(Character.toChars(char.code + 65248))
} else {
sb.append(char)
}
}
}
}
packet.message = sb.toString()
}
}
}
return sb.toString()
}

private fun processRandomCharMode(message: String, chance: Double): String {
val sb = StringBuilder()
for (char in message.toCharArray()) {
sb.append(char)
if (chance < chanceValue) {
sb.append((RandomUtils.nextInt(minUnicodeValue.get(), maxUnicodeValue.get())).toChar())
if (packet.message.length > 100) {
packet.message = packet.message.substring(0, 100)
}
}
return sb.toString()
}

private fun processUnicodeMode(message: String): String {
return message.map { char ->
if (char.code in 33..128) Character.toChars(char.code + 65248).joinToString("") else char.toString()
}.joinToString("")
}

private fun processRandomUnicodeMode(message: String, chance: Double): String {
return message.map { char ->
if ((chance < chanceValue) && (char.code in 33..128)) Character.toChars(char.code + 65248).joinToString("") else char.toString()
}.joinToString("")
}

override val tag: String
get() = modeValue
}

0 comments on commit d51b2d5

Please sign in to comment.