toSet
wraps the provided values into a ValidatedSet with this field as validation
Return
ValidatedSet wrapping the provided values and this field as validation
Author
fzzyhmstrs
Since
0.3.1
Parameters
elements
the inputs for the set generation. Same type as this field
Samples
import me.fzzyhmstrs.fzzy_config.util.EnumTranslatable
import me.fzzyhmstrs.fzzy_config.validation.Shorthand.validated
import me.fzzyhmstrs.fzzy_config.validation.collection.*
import me.fzzyhmstrs.fzzy_config.validation.minecraft.ValidatedIdentifier
import me.fzzyhmstrs.fzzy_config.validation.misc.ValidatedBoolean
import me.fzzyhmstrs.fzzy_config.validation.misc.ValidatedString
import me.fzzyhmstrs.fzzy_config.validation.number.ValidatedInt
import net.minecraft.registry.RegistryKeys
import net.minecraft.util.Identifier
fun main() {
//sampleStart
//validated set, based on TestEnum, validation limiting to those keys
val validatedSet = ValidatedSet(setOf(KeyEnum.KEY_1), KeyEnum::class.java.validated())
//wraps the vararg valued provided with a blank validated field (identifiers in this case). validation with actual bounds and logic can of course be used too
val setFromFieldArg = ValidatedIdentifier().toSet(Identifier.of("stick"), Identifier.of("blaze_rod"))
//wraps the collection provided with a blank validated field (identifiers in this case). validation with actual bounds and logic can of course be used too
val setFromFieldCollection = ValidatedIdentifier().toSet(setOf(Identifier.of("wooden_sword"), Identifier.of("stone_sword")))
//fields and sections have lang keys based on their "location" in the Config class graph.
//Lange key composition is as follows
//1. the namespace of the config id: (my_mod)
//2. the path of the config id: (my_mod.my_config)
//3. any parent ConfigSection field names as declared in-code: (my_mod.my_config.subSection)
//4. the setting field name as declared in-code: (my_mod.my_config.subSection.fieldName)
val fieldLang = """
{
"_comment1": "the lang for an example 'fieldName' setting in a config inside section 'subSection'",
"my_mod.my_config.subSection.fieldName": "Very Important Setting",
"my_mod.my_config.subSection.fieldName.desc": "This very important setting is used in this very important way."
}
"""
//sampleEnd
}
wraps the provided collection into a ValidatedSet with this field as validation
Return
ValidatedSet wrapping the collection and this field as validation
Author
fzzyhmstrs
Since
0.3.1
Parameters
collection
the collection to wrap. Same type as this field
Samples
import me.fzzyhmstrs.fzzy_config.util.EnumTranslatable
import me.fzzyhmstrs.fzzy_config.validation.Shorthand.validated
import me.fzzyhmstrs.fzzy_config.validation.collection.*
import me.fzzyhmstrs.fzzy_config.validation.minecraft.ValidatedIdentifier
import me.fzzyhmstrs.fzzy_config.validation.misc.ValidatedBoolean
import me.fzzyhmstrs.fzzy_config.validation.misc.ValidatedString
import me.fzzyhmstrs.fzzy_config.validation.number.ValidatedInt
import net.minecraft.registry.RegistryKeys
import net.minecraft.util.Identifier
fun main() {
//sampleStart
//validated set, based on TestEnum, validation limiting to those keys
val validatedSet = ValidatedSet(setOf(KeyEnum.KEY_1), KeyEnum::class.java.validated())
//wraps the vararg valued provided with a blank validated field (identifiers in this case). validation with actual bounds and logic can of course be used too
val setFromFieldArg = ValidatedIdentifier().toSet(Identifier.of("stick"), Identifier.of("blaze_rod"))
//wraps the collection provided with a blank validated field (identifiers in this case). validation with actual bounds and logic can of course be used too
val setFromFieldCollection = ValidatedIdentifier().toSet(setOf(Identifier.of("wooden_sword"), Identifier.of("stone_sword")))
//fields and sections have lang keys based on their "location" in the Config class graph.
//Lange key composition is as follows
//1. the namespace of the config id: (my_mod)
//2. the path of the config id: (my_mod.my_config)
//3. any parent ConfigSection field names as declared in-code: (my_mod.my_config.subSection)
//4. the setting field name as declared in-code: (my_mod.my_config.subSection.fieldName)
val fieldLang = """
{
"_comment1": "the lang for an example 'fieldName' setting in a config inside section 'subSection'",
"my_mod.my_config.subSection.fieldName": "Very Important Setting",
"my_mod.my_config.subSection.fieldName.desc": "This very important setting is used in this very important way."
}
"""
//sampleEnd
}