AutoConfig module

AutoConfig: 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/ModuleAutoConfig.ktKotlin · 153 lines · 5.3 KB

Automatically applies the correct config for the server you are playing on.

ModuleAutoConfig.ktKotlin · Minecraft 26.2 · 153 lines · 5.3 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 kotlinx.coroutines.launch
23
import net.ccbluex.liquidbounce.config.autoconfig.AutoConfig
24
import net.ccbluex.liquidbounce.event.eventListenerScope
25
import net.ccbluex.liquidbounce.event.events.NotificationEvent
26
import net.ccbluex.liquidbounce.event.events.ServerConnectEvent
27
import net.ccbluex.liquidbounce.event.handler
28
import net.ccbluex.liquidbounce.features.misc.SelfDestruct
29
import net.ccbluex.liquidbounce.features.module.ClientModule
30
import net.ccbluex.liquidbounce.features.module.ModuleCategories
31
import net.ccbluex.liquidbounce.utils.text.dropPort
32
import net.ccbluex.liquidbounce.utils.client.markAsError
33
import net.ccbluex.liquidbounce.utils.client.notification
34
import net.ccbluex.liquidbounce.utils.client.regular
35
import net.ccbluex.liquidbounce.utils.text.rootDomain
36
import net.minecraft.client.gui.screens.ConnectScreen
37
38
object ModuleAutoConfig : ClientModule(
39
    "AutoConfig",
40
    ModuleCategories.MISC,
41
    state = true,
42
    aliases = listOf("AutoSettings")
43
) {
44
45
    private val blacklistedServer = mutableListOf(
46
        // Common anticheat test server
47
        "poke.sexy",
48
        "loyisa.cn",
49
        "anticheat-test.com"
50
    )
51
    @Volatile
52
    private var isScheduled = false
53
54
    init {
55
        doNotIncludeAlways()
56
    }
57
58
    override suspend fun enabledEffect() {
59
        val currentServerEntry = mc.currentServer
60
61
        if (currentServerEntry == null) {
62
            notification(
63
                "AutoConfig", "You are not connected to a server.",
64
                NotificationEvent.Severity.ERROR
65
            )
66
            return
67
        }
68
69
        loadServerConfig(currentServerEntry.ip.dropPort().rootDomain(), null)
70
    }
71
72
    @Suppress("unused")
73
    private val handleServerConnect = handler<ServerConnectEvent> { event ->
74
        if (isScheduled) {
75
            return@handler
76
        }
77
78
        // This will stop us from connecting to the server right away
79
        event.cancelEvent()
80
81
        eventListenerScope.launch {
82
            try {
83
                isScheduled = true
84
                val address = event.serverInfo.ip.dropPort().rootDomain()
85
86
                loadServerConfig(address, event.connectScreen)
87
            } finally {
88
                // Proceed to connect to the server
89
                event.connectScreen.connect(mc, event.address, event.serverInfo, event.cookieStorage)
90
                isScheduled = false
91
            }
92
        }
93
    }
94
95
    /**
96
     * Loads the config for the given server address
97
     */
98
    private suspend fun loadServerConfig(
99
        address: String,
100
        connectScreen: ConnectScreen? = null
101
    ) {
102
        if (blacklistedServer.any { address.endsWith(it, true) }) {
103
            notification(
104
                "Auto Config", "This server is blacklisted.",
105
                NotificationEvent.Severity.INFO
106
            )
107
            return
108
        }
109
110
        // Get config with the shortest name, as it is most likely the correct one.
111
        // There can be multiple configs for the same server, but with different names
112
        // and the global config is likely named e.g "hypixel", while the more specific ones are named
113
        // "hypixel-csgo", "hypixel-legit", etc.
114
        val autoConfig = (AutoConfig.configs ?: return).filter { config ->
115
            config.serverAddress?.rootDomain().equals(address, true) ||
116
                config.serverAddress.equals(address, true)
117
        }.minByOrNull { config -> config.name.length }
118
119
        if (autoConfig == null) {
120
            notification(
121
                "Auto Config", "There is no known config for $address.",
122
                NotificationEvent.Severity.ERROR
123
            )
124
            return
125
        }
126
127
        connectScreen?.updateStatus(regular(message("loading", address)))
128
        runCatching {
129
            AutoConfig.loadAutoConfig(autoConfig)
130
        }.onFailure { error ->
131
            logger.error("Failed to load config ${autoConfig.name} for $address.", error)
132
            connectScreen?.updateStatus(markAsError(message("failed", address)))
133
            notification(
134
                "Auto Config", "Failed to load config ${autoConfig.name}.",
135
                NotificationEvent.Severity.ERROR
136
            )
137
        }.onSuccess {
138
            connectScreen?.updateStatus(regular(message("loaded", address)))
139
            notification(
140
                "Auto Config", "Successfully loaded config ${autoConfig.name}.",
141
                NotificationEvent.Severity.SUCCESS
142
            )
143
        }
144
    }
145
146
    /**
147
     * Overwrites the condition requirement for being in-game
148
     */
149
    override val running
150
        get() = !SelfDestruct.isDestructed && enabled
151
152
}
153