Creating a Config
First we need an @Serializable (kotlinx.serialization) data class
Here's an example
@Serializable
data class ConfigData(val debug: Boolean)Now that we have out config class we can create our KotlinXVoidFig
object Config: KotlinXVoidFig<ConfigData>(
Identifier("test_mod", "config"),
Side.COMMON,
//default config
ConfigData(false),
//Or any other `StringFormat`
Json { prettyPrint = true },
//serializer() function auto generated by @Serializable
ConfigData.serializer(),
//file type
"json"
) {
//functions used to facilitate syncing of common configs
override fun matches(other: VoidFig): Boolean {
if (other !is VFig) return false
val otherConfig: ClientConfig = other.getConfig()
return matchesOther(otherConfig)
}
override fun matchesRawData(other: String): Boolean {
val otherConfig: ClientConfig = deserialize(other)
return matchesOther(otherConfig)
}
private fun matchesOther(otherConfig: ClientConfig): Boolean {
return config.debug == otherConfig.debug
}
}Don't forget to register your config
Go look at the registering page!!!