From 856f5e0e815c8ef3be77ef342e1b0ca91aab8b0a Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sun, 22 Dec 2024 16:08:31 +0100 Subject: fix: Add choice options to YACL integration --- src/main/kotlin/features/mining/PickaxeAbility.kt | 1 - src/main/kotlin/gui/config/ChoiceHandler.kt | 1 + src/main/kotlin/gui/config/ManagedConfig.kt | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/features/mining/PickaxeAbility.kt b/src/main/kotlin/features/mining/PickaxeAbility.kt index a184c81..94b49f9 100644 --- a/src/main/kotlin/features/mining/PickaxeAbility.kt +++ b/src/main/kotlin/features/mining/PickaxeAbility.kt @@ -50,7 +50,6 @@ object PickaxeAbility : FirmamentFeature { val drillFuelBar by toggle("fuel-bar") { true } val blockOnPrivateIsland by choice( "block-on-dynamic", - BlockPickaxeAbility.entries, ) { BlockPickaxeAbility.ONLY_DESTRUCTIVE } diff --git a/src/main/kotlin/gui/config/ChoiceHandler.kt b/src/main/kotlin/gui/config/ChoiceHandler.kt index 25e885a..2ea3efc 100644 --- a/src/main/kotlin/gui/config/ChoiceHandler.kt +++ b/src/main/kotlin/gui/config/ChoiceHandler.kt @@ -13,6 +13,7 @@ import moe.nea.firmament.util.ErrorUtil import moe.nea.firmament.util.json.KJsonOps class ChoiceHandler( + val enumClass: Class, val universe: List, ) : ManagedConfig.OptionHandler where E : Enum, E : StringIdentifiable { val codec = StringIdentifiable.createCodec { diff --git a/src/main/kotlin/gui/config/ManagedConfig.kt b/src/main/kotlin/gui/config/ManagedConfig.kt index ea55f67..641b673 100644 --- a/src/main/kotlin/gui/config/ManagedConfig.kt +++ b/src/main/kotlin/gui/config/ManagedConfig.kt @@ -118,17 +118,17 @@ abstract class ManagedConfig( protected fun choice( propertyName: String, - universe: List, + enumClass: Class, default: () -> E ): ManagedOption where E : Enum, E : StringIdentifiable { - return option(propertyName, default, ChoiceHandler(universe)) + return option(propertyName, default, ChoiceHandler(enumClass, enumClass.enumConstants.toList())) } protected inline fun choice( propertyName: String, noinline default: () -> E ): ManagedOption where E : Enum, E : StringIdentifiable { - return choice(propertyName, enumEntries(), default) + return choice(propertyName, E::class.java, default) } private fun createStringIdentifiable(x: () -> Array): Codec where E : Enum, E : StringIdentifiable { -- cgit