forked from sery/kittyconfig
dumb kotlin config library you shouldn't use
- Kotlin 100%
| buildSrc | quoip | |
| core | commit | |
| gradle/wrapper | wowwowo | |
| gradle-plugin | commit | |
| json5 | commit | |
| minecraft | commit | |
| processor | commit | |
| test | commit | |
| toml | commit | |
| .gitignore | loots of stuf | |
| build.gradle.kts | quoip | |
| gradle.properties | commit | |
| gradlew | commit 1 | |
| gradlew.bat | commit 1 | |
| libs.versions.toml | commit | |
| LICENSE | uhhh | |
| README.md | Update README.md | |
| settings.gradle.kts | meow | |
kittyconfigg :3
A silly kotlin config library heavily integrated with kotlinx.serialization.
Gradle
settings.gradle.kts
pluginManagement {
repositories {
maven(url = "https://maven.is-immensely.gay/nightly")
}
}
build.gradle.kts
plugins {
// Apply the kitty config gradle plugin in addition to any others u may use
id("uwu.serenity.kittyconfig") version "<version>"
}
repositories {
// Once kitty config is stable change this to releases
// If using json5 u will additionally need the releases repo for json5k
maven(url = "https://maven.is-immensely.gay/nightly")
mavenCentral()
}
dependencies {
// should pull in kotlinx.serialization transitively
implementation("uwu.serenity.kittyconfig:kittyconfig:<version>")
// If you also want a bundled formt (json5 or toml)
implementation("uwu.serenity.kittyconfig:kittyconfig-<format>:<version>")
// If you are making a minecraft mod, you wanna depend on kittyconfig-mc instead
// Example: fabric loom
modImplementation("uwu.serenity.kittyconfig:kittyconfig-mc:<version>") {
// Extensions proviced by the gradle plugin :3
loader = "<loader>"
version = "<version>"
}
}
Usage
@Config(
id = "<id>",
format = MyFormat::class, // Optional, will use default format provided by plguins (if available) when none is specified
implicitContextual = true // Optional, defaults to true
)
// If using kittyconfig-mc we can also specify our config to be synced to client
/* @SyncToClient */
object MyConfig {
@Comment("This is a silly comment")
var mySillyField: Boolean = true
@Comment("""
Multiple lines of dumb
words
""")
var mySillyCollectionField: List<String> = listOf("awawa", "awaww")
var mySerializableField: MySerializableClass = MySerializableClass()
var customSerializerField: @Serializable(SomeClassSerializer::class) SomeClass = Uwu()
@Comment("Categories can also have comments")
object Category {
@Comment("An int field with range")
var intFieldWithRange: @Range(0, 5) Int = 3
var stringWIthPattern: @Pattern("[0-9a-z/]+") String = "meow"
}
}
To load a config, do
fun main() {
loadConfig(MyConfig, /* optionally provide a directory */)
}