Skip to content

Commit c00fd6a

Browse files
committed
Fixed config save
1 parent 1c4e8ea commit c00fd6a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

common/src/main/kotlin/com/lambda/config/Configuration.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ abstract class Configuration : Jsonable {
6262
get() = File("${primary.parent}/${primary.nameWithoutExtension}-backup.${primary.extension}")
6363

6464
init {
65-
listenUnsafe<ClientEvent.Startup> { tryLoad() }
65+
tryLoad() // ToDo: This will do at the moment but i'd like to run this at the first first loadable stage
6666
listenUnsafe<ClientEvent.Shutdown>(Int.MIN_VALUE) { trySave() }
6767

6868
register()
@@ -96,11 +96,11 @@ abstract class Configuration : Jsonable {
9696
}
9797

9898
fun save() = runCatching {
99-
primary.createIfNotExists {
100-
it.parentFile.mkdirs()
101-
it.writeText(gson.toJson(toJson()))
102-
it.copyTo(backup, true)
103-
}
99+
primary.createIfNotExists()
100+
.let {
101+
it.writeText(gson.toJson(toJson()))
102+
it.copyTo(backup, true)
103+
}
104104
}
105105

106106
/**

0 commit comments

Comments
 (0)