File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -33,14 +33,15 @@ data class MyConfig(
33
33
34
34
class MyPlugin : JavaPlugin () {
35
35
var myConfig: MyConfig = MyConfig (" " , null )
36
+ val configJson: Json = Json { prettyPrint = true ; encodeDefaults = true }
36
37
37
38
override fun onEnable (): Unit {
38
- this .myConfig = Json . Default .decodeFromString(File (dataFolder, " config.json" ).readText())
39
+ this .myConfig = configJson .decodeFromString(File (dataFolder, " config.json" ).readText())
39
40
// or Json.decodeFromString
40
41
}
41
42
42
43
override fun onDisable (): Unit {
43
- File (dataFolder, " config.json" ).writeText(Json . Default .encodeToString(this .myConfig))
44
+ File (dataFolder, " config.json" ).writeText(configJson .encodeToString(this .myConfig))
44
45
// or Json.encodeToString
45
46
}
46
47
}
You can’t perform that action at this time.
0 commit comments