Make SchematicType static init type safe

This commit is contained in:
2025-10-26 13:14:11 +01:00
parent dfbeab7b90
commit 79ebdcea85
5 changed files with 27 additions and 9 deletions
@@ -23,12 +23,14 @@ import de.steamwar.ImplementationProvider;
import java.io.File;
public interface SQLWrapper {
SQLWrapper impl = ImplementationProvider.getImpl("de.steamwar.sql.SQLWrapperImpl");
public interface SQLWrapper<M> {
SQLWrapper<?> impl = ImplementationProvider.getImpl("de.steamwar.sql.SQLWrapperImpl");
File getSchemTypesFolder();
default void processSchematicType(GameModeConfig<String, String> gameModeConfig) {
GameModeConfig<M, String> loadGameModeConfig(File file);
default void processSchematicType(GameModeConfig<?, String> gameModeConfig) {
}
void additionalExceptionMetadata(StringBuilder builder);
@@ -46,7 +46,7 @@ public class SchematicType {
File folder = SQLWrapper.impl.getSchemTypesFolder();
if (folder.exists()) {
for (File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
GameModeConfig<String, String> gameModeConfig = new GameModeConfig<>(configFile, GameModeConfig.ToString, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear);
GameModeConfig<?, String> gameModeConfig = SQLWrapper.impl.loadGameModeConfig(configFile);
if (gameModeConfig.Schematic.Type == null) continue;
if (tmpFromDB.containsKey(gameModeConfig.Schematic.Type.toDB())) continue;
SchematicType current = gameModeConfig.Schematic.Type;