Simplify Configuration.ModifiableValues

This commit is contained in:
Username404 2021-06-05 11:40:44 +02:00
parent 0b3f3907d2
commit d2bd1c4742
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 2 additions and 2 deletions

View File

@ -20,13 +20,13 @@ import java.io.File
import kotlin.reflect.KProperty
object Configuration {
private val ModifiableValues: MutableMap<String, () -> ConfigValue> = mapOf(
private val ModifiableValues = mutableMapOf<String, () -> ConfigValue>(
"enabledFeatures" to { ConfigValueFactory.fromMap(enabledFeatures) },
"macros" to { ConfigValueFactory.fromIterable((ClickGui.components.find { it is ClickBox && it.isCategory(Category.MACROS) } as ClickBox).buttons.map {
Json.encodeToString(it as Macro)
}) },
"box_colors" to { ConfigValueFactory.fromAnyRef(mapOf<String, Int>(*ClickGui.clickboxes.filter { it.name != null }.map { it.name!!.key to it.color }.toTypedArray())) },
).toMutableMap()
)
private fun Config.withFullModifiableValues() = ModifiableValues.entries.fold(this) { previous, entry ->
previous.withValue(entry.key, entry.value())
}