forked from SteamWar/SteamWar
Unify SchematicType loading
This commit is contained in:
@@ -26,39 +26,21 @@ import de.steamwar.velocitycore.VelocityCore;
|
||||
import de.steamwar.velocitycore.commands.CheckCommand;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SQLWrapperImpl implements SQLWrapper {
|
||||
|
||||
@Override
|
||||
public void loadSchemTypes(List<SchematicType> tmpTypes, Map<String, SchematicType> tmpFromDB) {
|
||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
if(!folder.exists())
|
||||
return;
|
||||
public File getSchemTypesFolder() {
|
||||
return new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||
}
|
||||
|
||||
for(File file : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().toList()) {
|
||||
GameModeConfig<String, String, String> gameModeConfig = new GameModeConfig<>(file, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToInternalName);
|
||||
if (!gameModeConfig.Schematic.loaded) continue;
|
||||
if (tmpFromDB.containsKey(gameModeConfig.Schematic.Type.toLowerCase())) continue;
|
||||
|
||||
String shortcut = gameModeConfig.Schematic.Shortcut;
|
||||
String material = gameModeConfig.Schematic.Material;
|
||||
|
||||
SchematicType checktype = null;
|
||||
if (!gameModeConfig.CheckQuestions.isEmpty()) {
|
||||
checktype = new SchematicType("C" + gameModeConfig.Schematic.Type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material, true);
|
||||
tmpTypes.add(checktype);
|
||||
tmpFromDB.put(checktype.toDB(), checktype);
|
||||
CheckCommand.setCheckQuestions(checktype, gameModeConfig.CheckQuestions);
|
||||
}
|
||||
|
||||
SchematicType current = new SchematicType(gameModeConfig.Schematic.Type, shortcut, gameModeConfig.Server.loaded ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, gameModeConfig.Deadline, gameModeConfig.Schematic.ManualCheck);
|
||||
tmpTypes.add(current);
|
||||
tmpFromDB.put(gameModeConfig.Schematic.Type.toLowerCase(), current);
|
||||
if(checktype != null)
|
||||
CheckCommand.addFightType(checktype, current);
|
||||
@Override
|
||||
public void processSchematicType(GameModeConfig<String, String, String> gameModeConfig, SchematicType type) {
|
||||
if (!gameModeConfig.CheckQuestions.isEmpty()) {
|
||||
CheckCommand.setCheckQuestions(type.checkType(), gameModeConfig.CheckQuestions);
|
||||
}
|
||||
if (type.checkType() != null) {
|
||||
CheckCommand.addFightType(type.checkType(), type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user