Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion committed Apr 4, 2024
1 parent 0ab1ac1 commit 5027562
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,63 @@ modding in Fabric environments.

## Implementing
This implementation uses utility of the fabric-loom gradle plugin, so make sure you have it added to your build.
Keep in mind to replace `{version}` with the suitable version for you. It can be found on the releases tab.
Keep in mind to replace `VERSION` with the suitable version for you. It can be found on the releases tab.

##### `build.gradle.kts`
`build.gradle.kts`
```kotlin
repositories {
maven("https://repo.nyon.dev/releases")
}

dependencies {
include("dev.nyon:konfig:{version}")
include(modImplementation("dev.nyon:konfig:VERSION")!!)
}
```

### Simple Config

```kotlin
import net.fabricmc.api.ModInitializer
import dev.nyon.konfig.config.config
import dev.nyon.konfig.config.loadConfig
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.int
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import net.fabricmc.loader.api.FabricLoader

object YourModInitializer : ModInitializer {
var config: Config = Config()

override fun onInitialize() {
config(
FabricLoader.getInstance().configDir.resolve("my_cool_config.json"),
1,
Config()
) { jsonElement: JsonElement, version: Int? ->
return@config if (version == null) {
val jsonObject = jsonElement.jsonObject
Config(jsonObject["old_integer"]!!.jsonPrimitive.int)
} else {
null
}
}

config = loadConfig()
}
}

@Serializable
data class Config(
val integer: Int = 5
)

```

On shutdown or save in a config screen you can call the `saveConfig` function to save the config to disk.

### Other
⚠️ The development version is always the latest stable release of Minecraft.
Therefore, new features will only be available for the current and following Minecraft versions.

If you need help with any of my mods, just join my [discord server](https://nyon.dev/discord)
If you need help with any of my mods, just join my [discord server](https://nyon.dev/discord)

0 comments on commit 5027562

Please sign in to comment.