diff --git a/eco-api/src/main/kotlin/com/willfp/eco/core/config/ConfigHelpers.kt b/eco-api/src/main/kotlin/com/willfp/eco/core/config/ConfigHelpers.kt new file mode 100644 index 00000000..aa3f440d --- /dev/null +++ b/eco-api/src/main/kotlin/com/willfp/eco/core/config/ConfigHelpers.kt @@ -0,0 +1,22 @@ +@file:JvmName("ConfigExtensions") + +package com.willfp.eco.core.config + +import com.willfp.eco.core.config.interfaces.Config + +/** + * Helper class to create configs with a kotlin DSL. + */ +class DSLConfig internal constructor() : BuildableConfig() { + infix fun String.to(value: Any?) = + set(this, value) +} + +/** + * Helper function to create configs with a kotlin DSL. + * + * @param builder The builder. + * @return The config. + */ +fun config(builder: DSLConfig.() -> Unit): Config = + DSLConfig().apply(builder)