Skip to content

Commit 2d08eb6

Browse files
authored
Fix: Stop modules.json getting wiped on close (#349)
1 parent e8eb261 commit 2d08eb6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/main/kotlin/com/lambda/config/ConfigCategory.kt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ abstract class ConfigCategory : Loadable {
7171

7272
configCategories.add(this)
7373

74-
listenUnsafe<ClientEvent.Shutdown>({ Int.MIN_VALUE }) { trySaveToFile() }
74+
listenUnsafe<ClientEvent.Shutdown>({ Int.MIN_VALUE }) { internalTrySave(false) }
7575

7676
return super.load()
7777
}
@@ -118,7 +118,10 @@ abstract class ConfigCategory : Loadable {
118118
}
119119

120120
private fun loadFromFile(file: File) = runCatching {
121-
file.ifNotExists { LOG.warn("No config file found for $name. Creating new file when saving.") }
121+
file.ifNotExists {
122+
check(!it.exists()) { "${it.name} is empty" }
123+
LOG.warn("No config file found for $name. Creating new file when saving.")
124+
}
122125
.ifExists {
123126
val parsed = mapper.readTree(it)
124127
if (!parsed.isObject) return@ifExists

0 commit comments

Comments
 (0)