Skip to content

Commit

Permalink
feat: basic configuration support
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Jan 11, 2025
1 parent dc53031 commit f2a68c9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/main/java/net/ccbluex/liquidbounce/config/SettingsUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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 -> {}
}

Expand All @@ -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)
}
}
}
Expand All @@ -215,4 +230,4 @@ object SettingsUtils {
}.trimEnd()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,6 +73,10 @@ class ModuleCommand(val module: Module, val values: Set<Value<*>> = module.value
chatSyntax("$moduleName ${args[1].lowercase()} <min>-<max>")
}

is ColorValue -> {
chatSyntax("$moduleName ${args[1].lowercase()} <hex/rainbow>")
}

else -> {}
}

Expand Down Expand Up @@ -187,6 +192,21 @@ class ModuleCommand(val module: Module, val values: Set<Value<*>> = 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
}

Expand Down

0 comments on commit f2a68c9

Please sign in to comment.