package dev.isxander.yacl3.dsl import dev.isxander.yacl3.api.Option import dev.isxander.yacl3.api.OptionDescription import dev.isxander.yacl3.api.OptionGroup import dev.isxander.yacl3.api.controller.ControllerBuilder import net.minecraft.network.chat.Component import kotlin.reflect.KMutableProperty0 fun Option.Builder.binding(property: KMutableProperty0, default: T) { binding(default, { property.get() }, { property.set(it) }) } fun Option.Builder.descriptionBuilder(block: OptionDescription.Builder.(T) -> Unit) { description { OptionDescription.createBuilder().apply { block(it) }.build() } } fun Option.Builder<*>.descriptionBuilderConst(block: OptionDescription.Builder.() -> Unit) { description(OptionDescription.createBuilder().apply(block).build()) } fun Option.Builder<*>.available(block: () -> Boolean) { available(block()) } fun OptionDescription.Builder.text(block: () -> Component) { text(block()) } fun OptionGroup.Builder.descriptionBuilder(block: OptionDescription.Builder.() -> Unit) { description(OptionDescription.createBuilder().apply(block).build()) } fun > Option.Builder.controller(builder: (Option) -> B, block: B.() -> Unit = {}) { controller { builder(it).apply(block) } }