Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleAutoAccount
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleAutoChatGame
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleAutoConfig
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleAutoPearl
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleAutoTPA
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleBetterTab
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleBookBot
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleEasyPearl
Expand Down Expand Up @@ -549,6 +550,7 @@ object ModuleManager : EventListener, Collection<ClientModule> by modules {
ModuleDebugRecorder,
ModuleAntiCheatDetect,
ModuleEasyPearl,
ModuleAutoTPA,

// Movement
ModuleAirJump,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2026 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/

package net.ccbluex.liquidbounce.features.module.modules.misc

import net.ccbluex.liquidbounce.config.types.list.Tagged
import net.ccbluex.liquidbounce.event.events.PacketEvent
import net.ccbluex.liquidbounce.event.events.PlayerTickEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.misc.FriendManager
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.features.module.ModuleCategories
import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleNotifier.sendNotifierMessage
import net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket

object ModuleAutoTPA : ClientModule("AutoTPA", ModuleCategories.MISC) {
Comment thread
minecrrrr marked this conversation as resolved.

private val mode by enumChoice("Command", Modes.TPACCEPT)
private val friendsOnly by boolean("OnlyFriends", true)

private val teleportMessages = arrayOf(
"has requested teleport", "просит телепортироваться", "хочет телепортироваться к вам",
"просит к вам телепортироваться", "хочет телепортироваться к вам.", "отправил вам запрос на телепортацию",
"/tpyes", "/tpaccept", "/tpno", "/tpdeny", "Z Запрос на телепортацию от", "Z Принять - /tpyes",
"Z Отклонить - /tpno", "has requested to teleport to you", "To teleport, type /tpaccept",
"To deny, type /tpdeny", "wants to teleport to you", "[Accept]", "[Deny]", "Incoming teleport request from",
"Teleport to you", "has sent a TPA request", "sent a teleport request to you", "[Accept", "[Deny", "accept]",
"deny]"
)

private val blacklistMessages = arrayOf(
"✉", "[ЛС]", "You]", "Я]", "Вы]", "I]", "» You", "-> You","» I", "-> I", "» Я", "-> Я",
"» Вы", "-> Вы", "You)", "Я)", "Вы)", "I)",
)

private var canAccept = false

@Suppress("unused")
private val onPacket = handler<PacketEvent> { e ->
val message = when (val packet = e.packet) {
is ClientboundSystemChatPacket -> packet.content().string
is ClientboundDisguisedChatPacket -> packet.message().string
else -> return@handler
}

if (isTeleportMessage(message)) {
if (friendsOnly) {
val matchedTrigger = teleportMessages.firstOrNull { message.contains(it, ignoreCase = true) } ?: ""
val cleanMessage = message.replace(matchedTrigger, "", ignoreCase = true)

canAccept = FriendManager.friends.any { cleanMessage.contains(it.name, ignoreCase = true) }
} else {
canAccept = true
}
}
}

@Suppress("unused")
private val onTick = handler<PlayerTickEvent> {
if (canAccept) {
canAccept = false
val player = mc.player ?: return@handler

player.connection.sendCommand(mode.tag)
val canSendMessage = ModuleNotifier.enabled && ModuleNotifier.autotpaMessages
if (canSendMessage) sendNotifierMessage("Teleport request accepted")
}
}

private fun isTeleportMessage(message: String): Boolean {
return teleportMessages.any { message.contains(it, ignoreCase = true) }
&& !blacklistMessages.any { message.contains(it, ignoreCase = true) }
}

private enum class Modes(override val tag: String) : Tagged {
TPACCEPT("tpaccept"),
TPYES("tpyes"),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package net.ccbluex.liquidbounce.features.module.modules.misc
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import joptsimple.internal.Messages
import net.ccbluex.liquidbounce.event.events.NotificationEvent
import net.ccbluex.liquidbounce.event.events.PacketEvent
import net.ccbluex.liquidbounce.event.events.PlayerTickEvent
Expand Down Expand Up @@ -73,6 +74,8 @@ object ModuleNotifier : ClientModule("Notifier", ModuleCategories.MISC) {
private val itemConsumptionMessages by boolean("ItemConsumptionMessages", true)
private val itemConsumptionMessageFormat by text("ItemConsumptionMessageFormat", $$"%1$s used %2$s")

val autotpaMessages by boolean("AutoTPAMessages", true)

private val heldItemMessages by boolean("HeldItemMessages", false)
private val heldItemMessageFormat by text("HeldItemMessageFormat", $$"%1$s holds %2$s x%3$s in %4$s")
private val heldItems by items("HeldItems", itemSortedSetOf(Items.END_CRYSTAL, Items.ENCHANTED_GOLDEN_APPLE))
Expand Down Expand Up @@ -320,7 +323,7 @@ object ModuleNotifier : ClientModule("Notifier", ModuleCategories.MISC) {
)
}

private fun sendNotifierMessage(message: String) {
fun sendNotifierMessage(message: String) {
if (useNotification) {
notification(this.name, message, NotificationEvent.Severity.INFO)
} else {
Expand Down
Loading