Improve YMLWrapper

This commit is contained in:
2025-10-26 09:14:34 +01:00
parent 4405d9c25d
commit aec03e41a1
14 changed files with 163 additions and 314 deletions
@@ -19,7 +19,8 @@
package de.steamwar.sql
import org.bspfsystems.yamlconfiguration.file.YamlConfiguration
import de.steamwar.data.GameModeConfig
import de.steamwar.data.YMLWrapper
import java.io.File
import java.util.*
import java.util.stream.Collectors
@@ -29,32 +30,26 @@ fun loadSchematicTypes(tmpTypes: MutableList<SchematicType>?, tmpFromDB: Mutable
if (folder.exists()) {
for (configFile in Arrays.stream(folder.listFiles { _, name -> name.endsWith(".yml") && !name.endsWith(".kits.yml") })
.sorted().collect(Collectors.toList())) {
val config: YamlConfiguration = YamlConfiguration.loadConfiguration(configFile)
if (!config.isConfigurationSection("Schematic")) continue
val type: String = config.getString("Schematic.Type")!!
val shortcut = config.getString("Schematic.Shortcut")
if (shortcut == null) {
println("No shortcut for $type")
continue
}
val gameModeConfig = GameModeConfig(configFile, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToString, YMLWrapper.ToStaticWarGear)
if (!gameModeConfig.Schematic.loaded) continue
val type = gameModeConfig.Schematic.Type
checkNotNull(type)
val shortcut = gameModeConfig.Schematic.Shortcut
if (tmpFromDB!!.containsKey(type.lowercase(Locale.getDefault()))) continue
var checktype: SchematicType? = null
val material: String = config.getString("Schematic.Material", "STONE_BUTTON")!!
if (!config.getStringList("CheckQuestions").isEmpty()) {
checktype = SchematicType("C$type", "C$shortcut", SchematicType.Type.CHECK_TYPE, null, material, false)
val material = gameModeConfig.Schematic.Material
if (!gameModeConfig.CheckQuestions.isEmpty()) {
checktype = SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true)
tmpTypes!!.add(checktype)
tmpFromDB[checktype.toDB()] = checktype
tmpFromDB.put(checktype.toDB(), checktype)
}
val current = SchematicType(
type,
shortcut,
if (config.isConfigurationSection("Server")) SchematicType.Type.FIGHT_TYPE else SchematicType.Type.NORMAL,
checktype,
material,
false
)
val current = SchematicType(type, shortcut, if (gameModeConfig.Server.loaded) SchematicType.Type.FIGHT_TYPE else SchematicType.Type.NORMAL, checktype, material, gameModeConfig.Deadline, gameModeConfig.Schematic.ManualCheck)
tmpTypes!!.add(current)
tmpFromDB[type.lowercase(Locale.getDefault())] = current
tmpFromDB.put(type.lowercase(Locale.getDefault()), current)
}
}
}