Fixed config bugs

This commit is contained in:
Auxilor
2022-03-22 16:53:16 +00:00
parent 12f355b205
commit 376e3284fb
2 changed files with 17 additions and 3 deletions

View File

@@ -83,7 +83,21 @@ open class EcoJSONConfigWrapper : Config {
section.setRecursively(remainingPath, obj)
}
values[path] = if (obj is Config) obj.toMap() else obj
values[path] = when (obj) {
is Config -> obj.toMap()
is Collection<*> -> {
val first = obj.firstOrNull()
if (first is Config) {
obj as Collection<Config>
obj.map { it.toMap() }
} else if (obj.isEmpty()) {
mutableListOf()
} else {
obj.toList()
}
}
else -> obj
}
}
override fun getKeys(deep: Boolean): List<String> {

View File

@@ -61,9 +61,9 @@ open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
obj as Collection<Config>
obj.map { it.toBukkit() }
} else if (obj.isEmpty()) {
emptyList()
mutableListOf() // Don't use EmptyList, causes anchors as they have the same reference
} else {
obj
obj.toList()
}
}
else -> obj