From f2a68c9041fe24377e525e042901031d220cbbf4 Mon Sep 17 00:00:00 2001 From: Zywl <86253343+opZywl@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:36:20 -0300 Subject: [PATCH] feat: basic configuration support --- .../liquidbounce/config/SettingsUtils.kt | 21 ++++++++++++++++--- .../features/module/ModuleCommand.kt | 20 ++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/config/SettingsUtils.kt b/src/main/java/net/ccbluex/liquidbounce/config/SettingsUtils.kt index 36ece9a8de..233c1743e9 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/SettingsUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/SettingsUtils.kt @@ -16,6 +16,7 @@ import net.ccbluex.liquidbounce.utils.io.HttpUtils import net.ccbluex.liquidbounce.utils.kotlin.StringUtils import net.ccbluex.liquidbounce.utils.render.ColorUtils.translateAlternateColorCodes import org.lwjgl.input.Keyboard +import java.awt.Color import kotlin.reflect.KMutableProperty0 /** @@ -169,6 +170,20 @@ object SettingsUtils { } else (moduleValue as FloatRangeValue).changeValue(min..max) } } + is ColorValue -> { + moduleValue.readColorFromConfig(value)?.let { list -> + val hexColor = list[0] + val rainbowFlag = list[1].toBoolean() + + val argb = hexColor.toLongOrNull(16)?.toInt() + + if (argb != null) { + moduleValue.setColor(Color(argb, true)) + } + + moduleValue.rainbow = rainbowFlag + } + } else -> {} } @@ -194,10 +209,10 @@ object SettingsUtils { if (values) { for (value in module.values) { if (all || !value.subjective && value.shouldRender()) { - val valueString = "${module.name} ${value.name} ${value.get()}" + val valueString = "${module.name} ${value.name} ${value.getString()}" if (valueString.isNotBlank()) { - appendLine("${module.name} ${value.name} ${value.get()}") + appendLine(valueString) } } } @@ -215,4 +230,4 @@ object SettingsUtils { }.trimEnd() } -} +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/ModuleCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/ModuleCommand.kt index 7852281199..550e88de59 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/ModuleCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/ModuleCommand.kt @@ -11,6 +11,7 @@ import net.ccbluex.liquidbounce.utils.block.BlockUtils.getBlockName import net.ccbluex.liquidbounce.utils.kotlin.StringUtils import net.minecraft.block.Block import net.minecraft.item.Item +import java.awt.Color /** * Module command @@ -72,6 +73,10 @@ class ModuleCommand(val module: Module, val values: Set> = module.value chatSyntax("$moduleName ${args[1].lowercase()} -") } + is ColorValue -> { + chatSyntax("$moduleName ${args[1].lowercase()} ") + } + else -> {} } @@ -187,6 +192,21 @@ class ModuleCommand(val module: Module, val values: Set> = module.value value.set(string) to string } + is ColorValue -> { + val str = args[2] + + str.toBooleanStrictOrNull()?.let { + value.rainbow = it + + chat("§7${module.getName()} §8rainbow§7 was set to §8${value.rainbow}§7.") + return + } + + str.toLongOrNull(16)?.toInt()?.let { + value.set(Color(it, true)) to str + } ?: return + } + else -> return }