forked from SteamWar/SteamWar
Unify SchematicType loading
This commit is contained in:
@@ -19,42 +19,12 @@
|
||||
|
||||
package de.steamwar.sql
|
||||
|
||||
import de.steamwar.data.GameModeConfig
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.stream.Collectors
|
||||
|
||||
fun loadSchematicTypes(tmpTypes: MutableList<SchematicType>?, tmpFromDB: MutableMap<String, SchematicType>?) {
|
||||
val folder = File("/configs/GameModes")
|
||||
if (folder.exists()) {
|
||||
for (configFile in Arrays.stream(folder.listFiles { _, name -> name.endsWith(".yml") && !name.endsWith(".kits.yml") })
|
||||
.sorted().collect(Collectors.toList())) {
|
||||
val gameModeConfig = GameModeConfig(configFile, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.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 = gameModeConfig.Schematic.Material
|
||||
|
||||
if (!gameModeConfig.CheckQuestions.isEmpty()) {
|
||||
checktype = SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true)
|
||||
tmpTypes!!.add(checktype)
|
||||
tmpFromDB.put(checktype.toDB(), checktype)
|
||||
}
|
||||
|
||||
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.put(type.lowercase(Locale.getDefault()), current)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SQLWrapperImpl: SQLWrapper {
|
||||
override fun loadSchemTypes(tmpTypes: MutableList<SchematicType>?, tmpFromDB: MutableMap<String, SchematicType>?) = loadSchematicTypes(tmpTypes, tmpFromDB)
|
||||
override fun getSchemTypesFolder(): File? {
|
||||
return File("/configs/GameModes")
|
||||
}
|
||||
|
||||
override fun additionalExceptionMetadata(builder: StringBuilder) {
|
||||
builder.append("\n\nWebsiteApi")
|
||||
|
||||
Reference in New Issue
Block a user