AntiStaff module

AntiStaff: Minecraft 26.3 cheat module, full source for every implementation (1 client: LiquidBounce (Kotlin)).

1 implementationMISC

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

LiquidBounce (Kotlin)MISCsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleAntiStaff.ktKotlin · 147 lines · 5.4 KB

Alerts you when the server's staff members are watching you.

SettingsShowInTabList
ModuleAntiStaff.ktKotlin · Minecraft 26.2 · 147 lines · 5.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
package net.ccbluex.liquidbounce.features.module.modules.misc
21
22
import net.ccbluex.liquidbounce.api.core.HttpException
23
import net.ccbluex.liquidbounce.api.services.cdn.ClientCdn.requestStaffList
24
import net.ccbluex.liquidbounce.event.events.NotificationEvent
25
import net.ccbluex.liquidbounce.event.events.PacketEvent
26
import net.ccbluex.liquidbounce.event.events.ServerConnectEvent
27
import net.ccbluex.liquidbounce.event.handler
28
import net.ccbluex.liquidbounce.event.sequenceHandler
29
import net.ccbluex.liquidbounce.event.tickUntil
30
import net.ccbluex.liquidbounce.features.module.ClientModule
31
import net.ccbluex.liquidbounce.features.module.ModuleCategories
32
import net.ccbluex.liquidbounce.utils.client.MessageMetadata
33
import net.ccbluex.liquidbounce.utils.client.chat
34
import net.ccbluex.liquidbounce.utils.text.dropPort
35
import net.ccbluex.liquidbounce.utils.client.inGame
36
import net.ccbluex.liquidbounce.utils.client.notification
37
import net.ccbluex.liquidbounce.utils.text.rootDomain
38
import net.ccbluex.liquidbounce.utils.client.warning
39
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket
40
41
/**
42
 * Notifies you about staff actions.
43
 */
44
object ModuleAntiStaff : ClientModule("AntiStaff", ModuleCategories.MISC) {
45
46
    private val showInTabList by boolean("ShowInTabList", true)
47
    private val serverStaffList = hashMapOf<String, Set<String>>()
48
49
    override suspend fun enabledEffect() {
50
        val serverEntry = mc.currentServer ?: return
51
        val address = serverEntry.ip.dropPort().rootDomain()
52
53
        if (serverStaffList.containsKey(address)) {
54
            return
55
        }
56
        serverStaffList[address] = emptySet()
57
58
        loadStaffList(address)
59
    }
60
61
    @Suppress("unused")
62
    val handleServerConnect = sequenceHandler<ServerConnectEvent> { event ->
63
        val address = event.serverInfo.ip.dropPort().rootDomain()
64
65
        if (serverStaffList.containsKey(address)) {
66
            return@sequenceHandler
67
        }
68
        serverStaffList[address] = emptySet()
69
70
        // Keeps us from loading the staff list multiple times
71
        tickUntil { inGame && mc.gui.screen() != null }
72
73
        // Load the staff list
74
        loadStaffList(address)
75
    }
76
77
    @Suppress("unused")
78
    private val packetHandler = handler<PacketEvent> { event ->
79
        val packet = event.packet
80
81
        if (packet is ClientboundPlayerInfoUpdatePacket) {
82
            // playerAdditionEntries returns empty if the packet is not marked with ADD_PLAYER
83
            val entries = packet.newEntries()
84
85
            for (entry in entries) {
86
                val profile = entry.profile ?: continue
87
88
                if (isStaff(profile.name)) {
89
                    alert("staffAlert", profile.name)
90
                }
91
            }
92
        }
93
    }
94
95
    suspend fun loadStaffList(address: String) {
96
        try {
97
            val staffs = requestStaffList(address)
98
            serverStaffList[address] = staffs
99
100
            logger.info("[AntiStaff] Loaded ${staffs.size} staff member for $address")
101
            notification("AntiStaff", message("staffsLoaded", staffs.size, address),
102
                NotificationEvent.Severity.SUCCESS)
103
        } catch (httpException: HttpException) {
104
            when (httpException.code) {
105
                404 -> notification("AntiStaff", message("noStaffs", address),
106
                    NotificationEvent.Severity.ERROR)
107
                else -> notification("AntiStaff", message("staffsFailed", address,
108
                    httpException.code), NotificationEvent.Severity.ERROR)
109
            }
110
        } catch (exception: Exception) {
111
            logger.error("Failed to load staff list of $address", exception)
112
            notification("AntiStaff", message("staffsFailed", address,
113
                exception.javaClass.simpleName), NotificationEvent.Severity.ERROR)
114
        }
115
    }
116
117
    fun shouldShowAsStaffOnTab(username: String): Boolean {
118
        if (!showInTabList || !running || !enabled) {
119
            return false
120
        }
121
122
        return isStaff(username)
123
    }
124
125
    private fun isStaff(username: String): Boolean {
126
        val serverEntry = mc.currentServer ?: return false
127
        val serverAddress = serverEntry.ip?.dropPort()?.rootDomain() ?: return false
128
        val staffs = serverStaffList[serverAddress] ?: return false
129
130
        return staffs.contains(username)
131
132
    }
133
134
    /**
135
     * Alert the user about staff watching them.
136
     */
137
    private fun alert(key: String, username: String? = null) {
138
        val message = message(key, username ?: "")
139
        notification("Staff Detected", message, NotificationEvent.Severity.INFO)
140
        chat(
141
            warning(message(key, username ?: "")),
142
            metadata = MessageMetadata(id = "${this.name}#${username ?: "generic"}")
143
        )
144
    }
145
146
}
147