Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(legacy): pop-up support #5574

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 0 additions & 8 deletions src/main/java/net/ccbluex/liquidbounce/LiquidBounce.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import kotlinx.coroutines.launch
import net.ccbluex.liquidbounce.api.ClientUpdate
import net.ccbluex.liquidbounce.api.ClientUpdate.gitInfo
import net.ccbluex.liquidbounce.api.loadSettings
import net.ccbluex.liquidbounce.api.messageOfTheDay
import net.ccbluex.liquidbounce.api.reloadMessageOfTheDay
import net.ccbluex.liquidbounce.cape.CapeService
import net.ccbluex.liquidbounce.event.ClientShutdownEvent
import net.ccbluex.liquidbounce.event.EventManager
Expand Down Expand Up @@ -136,9 +134,6 @@ object LiquidBounce {
// Check update
ClientUpdate.reloadNewestVersion()

// Get MOTD
reloadMessageOfTheDay()

// Load languages
loadLanguages()

Expand Down Expand Up @@ -231,9 +226,6 @@ object LiquidBounce {
// Disable Optifine FastRender
disableFastRender()

// Load message of the day
messageOfTheDay?.message?.let { LOGGER.info("Message of the day: $it") }

// Setup Discord RPC
if (showRPCValue) {
SharedScopes.IO.launch {
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/ccbluex/liquidbounce/api/ClientApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ object ClientApi {
}
}

fun getMessageOfTheDay(branch: String = HARD_CODED_BRANCH): MessageOfTheDay {
val url = "$API_V1_ENDPOINT/client/$branch/motd"
client.get(url).use { response ->
if (!response.isSuccessful) error("Request failed: ${response.code}")
return response.body.charStream().decodeJson()
}
}

fun getSettingsList(branch: String = HARD_CODED_BRANCH): List<AutoSettings> {
val url = "$API_V1_ENDPOINT/client/$branch/settings"
client.get(url).use { response ->
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/net/ccbluex/liquidbounce/api/MessageOfTheDay.kt

This file was deleted.

7 changes: 0 additions & 7 deletions src/main/java/net/ccbluex/liquidbounce/api/ResponseTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ data class Build(
val url: String
)

/**
* Message of the day
*
* Contains only a message
*/
data class MessageOfTheDay(val message: String)

/**
* Settings
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import net.ccbluex.liquidbounce.file.FileConfig
import net.ccbluex.liquidbounce.file.FileManager
import net.ccbluex.liquidbounce.file.FileManager.PRETTY_GSON
import net.ccbluex.liquidbounce.file.configs.models.ClientConfiguration
import net.ccbluex.liquidbounce.ui.client.GuiMainMenu
import net.ccbluex.liquidbounce.ui.client.altmanager.menus.altgenerator.GuiTheAltening.Companion.apiKey
import net.ccbluex.liquidbounce.utils.attack.EntityUtils.Targets
import net.ccbluex.liquidbounce.utils.io.readJson
Expand Down Expand Up @@ -87,6 +88,11 @@ class ValuesConfig(file: File) : FileConfig(file) {
if (jsonValue.has("Particles")) ClientConfiguration.particles = jsonValue["Particles"].asBoolean
}

key.equals("popupData", true) -> {
val jsonValue = value as JsonObject
if (jsonValue.has("lastWarningTime")) GuiMainMenu.lastWarningTime = jsonValue["lastWarningTime"].asLong
}

else -> {
val module = moduleManager[key] ?: continue

Expand Down Expand Up @@ -141,6 +147,10 @@ class ValuesConfig(file: File) : FileConfig(file) {
jsonObject.add(module.name, jsonModule)
}

val popupData = JsonObject()
GuiMainMenu.lastWarningTime?.let { popupData.addProperty("lastWarningTime", it) }
jsonObject.add("lastWarningTime", popupData)

file.writeText(PRETTY_GSON.toJson(jsonObject))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
package net.ccbluex.liquidbounce.injection.forge.mixins.client;

import net.ccbluex.liquidbounce.LiquidBounce;
import net.ccbluex.liquidbounce.api.ClientUpdate;
import net.ccbluex.liquidbounce.event.*;
import net.ccbluex.liquidbounce.features.module.modules.combat.AutoClicker;
import net.ccbluex.liquidbounce.features.module.modules.combat.TickBase;
import net.ccbluex.liquidbounce.features.module.modules.exploit.AbortBreaking;
import net.ccbluex.liquidbounce.features.module.modules.exploit.MultiActions;
import net.ccbluex.liquidbounce.features.module.modules.world.FastPlace;
import net.ccbluex.liquidbounce.file.FileManager;
import net.ccbluex.liquidbounce.file.configs.models.ClientConfiguration;
import net.ccbluex.liquidbounce.injection.forge.SplashProgressLock;
import net.ccbluex.liquidbounce.ui.client.GuiMainMenu;
import net.ccbluex.liquidbounce.ui.client.GuiUpdate;
import net.ccbluex.liquidbounce.ui.client.GuiWelcome;
import net.ccbluex.liquidbounce.utils.attack.CPSCounter;
import net.ccbluex.liquidbounce.utils.client.ClientUtils;
import net.ccbluex.liquidbounce.utils.inventory.SilentHotbar;
Expand Down Expand Up @@ -139,15 +135,6 @@ private void waitForLock(CallbackInfo ci) {
}
}

@Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V", shift = At.Shift.AFTER))
private void afterMainScreen(CallbackInfo callbackInfo) {
if (FileManager.INSTANCE.getFirstStart()) {
displayGuiScreen(new GuiWelcome());
} else if (ClientUpdate.INSTANCE.hasUpdate()) {
displayGuiScreen(new GuiUpdate());
}
}

@Inject(method = "createDisplay", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V", shift = At.Shift.AFTER))
private void createDisplay(CallbackInfo callbackInfo) {
if (ClientConfiguration.INSTANCE.getClientTitle()) {
Expand Down
187 changes: 148 additions & 39 deletions src/main/java/net/ccbluex/liquidbounce/ui/client/GuiMainMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
package net.ccbluex.liquidbounce.ui.client

import net.ccbluex.liquidbounce.LiquidBounce.CLIENT_NAME
import net.ccbluex.liquidbounce.LiquidBounce.CLIENT_WEBSITE
import net.ccbluex.liquidbounce.LiquidBounce.clientVersionText
import net.ccbluex.liquidbounce.api.messageOfTheDay
import net.ccbluex.liquidbounce.api.ClientUpdate
import net.ccbluex.liquidbounce.api.ClientUpdate.hasUpdate
import net.ccbluex.liquidbounce.file.FileManager
import net.ccbluex.liquidbounce.lang.translationMenu
import net.ccbluex.liquidbounce.ui.client.altmanager.GuiAltManager
import net.ccbluex.liquidbounce.ui.client.fontmanager.GuiFontManager
Expand All @@ -21,15 +22,41 @@ import net.minecraft.client.gui.GuiMultiplayer
import net.minecraft.client.gui.GuiOptions
import net.minecraft.client.gui.GuiSelectWorld
import net.minecraft.client.resources.I18n
import org.lwjgl.input.Mouse
import java.text.SimpleDateFormat
import java.time.Instant
import java.util.*
import java.util.concurrent.TimeUnit

class GuiMainMenu : AbstractScreen() {

private var popup: PopupScreen? = null

companion object {
private var popupOnce = false
var lastWarningTime: Long? = null
private val warningInterval = TimeUnit.DAYS.toMillis(7)
}

init {
if (!popupOnce) {
if (FileManager.firstStart) {
showWelcomePopup()
} else if (hasUpdate()) {
showUpdatePopup()
} else if (lastWarningTime == null || Instant.now().toEpochMilli() - lastWarningTime!! > warningInterval) {
showDiscontinuedWarning()
}
popupOnce = true
}
}

override fun initGui() {
val defaultHeight = height / 4 + 48

val baseCol1 = width / 2 - 100
val baseCol2 = width / 2 + 2

+GuiButton(100, baseCol1, defaultHeight + 24, 98, 20, translationMenu("altManager"))
+GuiButton(103, baseCol2, defaultHeight + 24, 98, 20, translationMenu("mods"))
+GuiButton(109, baseCol1, defaultHeight + 24 * 2, 98, 20, translationMenu("fontManager"))
Expand All @@ -47,6 +74,102 @@ class GuiMainMenu : AbstractScreen() {
+GuiButton(4, baseCol2, defaultHeight + 24 * 4, 98, 20, I18n.format("menu.quit"))
}

private fun showWelcomePopup() {
popup = PopupScreen(
"§a§lWelcome!",
"""
§eThank you for downloading and installing §bLiquidBounce§e!

§6Here is some information you might find useful:§r
§a- §fClickGUI:§r Press §7[RightShift]§f to open ClickGUI.
§a- §fRight-click modules with a '+' to edit.
§a- §fHover over a module to see its description.

§6Important Commands:§r
§a- §f.bind <module> <key> / .bind <module> none
§a- §f.config load <name> / .config list

§bNeed help? Contact us!§r
- §fYouTube: §9https://youtube.com/ccbluex
- §fTwitter: §9https://twitter.com/ccbluex
- §fForum: §9https://forums.ccbluex.net/
""".trimIndent(),
listOf(
ButtonData("§aOK") { }
),
{
popup = null
}
)
}

private fun showUpdatePopup() {
val newestVersion = ClientUpdate.newestVersion ?: return

val isReleaseBuild = newestVersion.release
val updateType = if (isReleaseBuild) "version" else "development build"

val dateFormatter = SimpleDateFormat("EEEE, MMMM dd, yyyy, h a z", Locale.ENGLISH)
val newestVersionDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(newestVersion.date)
val formattedNewestDate = dateFormatter.format(newestVersionDate)

val updateMessage = """
§eA new $updateType of LiquidBounce is available!

- ${if (isReleaseBuild) "§aVersion" else "§aBuild ID"}:§r ${if (isReleaseBuild) newestVersion.lbVersion else newestVersion.buildId}
- §aMinecraft Version:§r ${newestVersion.mcVersion}
- §aBranch:§r ${newestVersion.branch}
- §aDate:§r $formattedNewestDate

§6Changes:§r
${newestVersion.message}

§bUpgrade now to enjoy the latest features and improvements!§r
""".trimIndent()

popup = PopupScreen(
"§bNew Update Available!",
updateMessage,
listOf(
ButtonData("§aDownload") { MiscUtils.showURL(newestVersion.url) }
),
{
popup = null
}
)
}

private fun showDiscontinuedWarning() {
popup = PopupScreen(
"§c§lUnsupported version",
"""
§6§lThis version is discontinued and unsupported.§r

§eWe strongly recommend switching to §bLiquidBounce Nextgen§e,
which offers the following benefits:

§a- §fSupports all Minecraft versions from §71.7§f to §71.21+§f.
§a- §fFrequent updates with the latest bypasses and features.
§a- §fActive development and official support.
§a- §fImproved performance and compatibility.

§cWhy upgrade?§r
- No new bypasses or features will be introduced in this version.
- Auto config support will not be actively maintained.
- Unofficial forks of this version are discouraged as they lack the full feature set of Nextgen and cannot be trusted.

§9Upgrade to LiquidBounce Nextgen today for a better experience!§r
""".trimIndent(),
listOf(
ButtonData("§aDownload Nextgen") { MiscUtils.showURL("https://liquidbounce.net/download") },
ButtonData("§eInstallation Tutorial") { MiscUtils.showURL("https://www.youtube.com/watch?v=i_r1i4m-NZc") }
)
) {
popup = null
lastWarningTime = Instant.now().toEpochMilli()
}
}

override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
drawBackground(0)

Expand All @@ -67,52 +190,27 @@ class GuiMainMenu : AbstractScreen() {
true
)

val messageOfTheDay = messageOfTheDay?.message
if (messageOfTheDay?.isNotBlank() == true) {
val lines = messageOfTheDay.lines()

drawRoundedBorderRect(
width / 2f - 115,
height / 4f + 190,
width / 2f + 115,
height / 4f + 200 + (Fonts.fontSemibold35.fontHeight * lines.size),
2f,
Integer.MIN_VALUE,
Integer.MIN_VALUE,
3F
)
super.drawScreen(mouseX, mouseY, partialTicks)

// Draw rect below main rect and within draw MOTD text
for ((index, line) in lines.withIndex()) {
Fonts.fontSemibold35.drawCenteredString(
line, width / 2F, height / 4f + 197.5f
+ (Fonts.fontSemibold35.fontHeight * index), 0xffffff, true
)
}
if (popup != null) {
popup!!.drawScreen(width, height, mouseX, mouseY)
}

super.drawScreen(mouseX, mouseY, partialTicks)
}

override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) {
// When clicking the message of the day text
val messageOfTheDay = messageOfTheDay?.message
if (messageOfTheDay?.isNotBlank() == true) {
val lines = messageOfTheDay.lines()
val motdHeight = height / 4f + 198
val motdWidth = width / 2f - 115
val motdHeightEnd = motdHeight + 2 + (Fonts.fontSemibold35.fontHeight * lines.size)

if (mouseX >= motdWidth && mouseX <= width / 2f + 115 && mouseY >= motdHeight && mouseY <= motdHeightEnd) {
// Open liquidbounce website
MiscUtils.showURL("https://$CLIENT_WEBSITE")
}
if (popup != null) {
popup!!.mouseClicked(mouseX, mouseY, mouseButton)
return
}

super.mouseClicked(mouseX, mouseY, mouseButton)
}

override fun actionPerformed(button: GuiButton) {
if (popup != null) {
return
}

when (button.id) {
0 -> mc.displayGuiScreen(GuiOptions(this, mc.gameSettings))
1 -> mc.displayGuiScreen(GuiSelectWorld(this))
Expand All @@ -126,4 +224,15 @@ class GuiMainMenu : AbstractScreen() {
109 -> mc.displayGuiScreen(GuiFontManager(this))
}
}
}

override fun handleMouseInput() {
if (popup != null) {
val eventDWheel = Mouse.getEventDWheel()
if (eventDWheel != 0) {
popup!!.handleMouseWheel(eventDWheel)
}
}

super.handleMouseInput()
}
}
Loading