From a8c98594a99023520f2fe6c974460b79939e3e32 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 10 Nov 2025 11:31:59 +0100 Subject: [PATCH] Fix GameModeConfig.Schematic.SubTypes --- .../src/de/steamwar/sql/GameModeConfig.java | 19 +++++++++++++++++++ .../SQL/src/de/steamwar/sql/YMLWrapper.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index 2e6fe55d..cea9fe57 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -71,11 +71,15 @@ public final class GameModeConfig { } private static final Field Schematic_TypeField; + private static final Field Schematic_SubTypesField; static { try { Schematic_TypeField = SchematicConfig.class.getDeclaredField("Type"); Schematic_TypeField.setAccessible(true); + + Schematic_SubTypesField = SchematicConfig.class.getDeclaredField("SubTypes"); + Schematic_SubTypesField.setAccessible(true); } catch (NoSuchFieldException e) { throw new SecurityException(e.getMessage(), e); } @@ -85,6 +89,18 @@ public final class GameModeConfig { bySchematicType = new HashMap<>(); SchematicType.values(); DEFAULTS = SQLWrapper.impl.loadGameModeConfig(null); + + byFileName.values().forEach(gameModeConfig -> { + List subTypes = Collections.unmodifiableList(gameModeConfig.Schematic.SubTypesStrings.stream() + .map(SchematicType::fromDB) + .filter(Objects::nonNull) + .collect(Collectors.toList())); + try { + Schematic_SubTypesField.set(gameModeConfig.Schematic, subTypes); + } catch (IllegalAccessException e) { + throw new SecurityException(e.getMessage(), e); + } + }); } public final boolean loaded; @@ -524,6 +540,8 @@ public final class GameModeConfig { */ public final SchematicType Type; + private final List SubTypesStrings; + /** * The schematic types that are also allowed to be chosen in this arena */ @@ -631,6 +649,7 @@ public final class GameModeConfig { Size = new SizeConfig(loader.with("Size")); Inset = new InsetConfig(loader.with("Inset")); Type = loader.getSchematicType("Type", "Normal"); + SubTypesStrings = loader.getStringList("SubTypes"); SubTypes = loader.getSchematicTypeList("SubTypes"); Shortcut = loader.getString("Shortcut", ""); Material = loader.getMaterial("Material", "STONE_BUTTON"); diff --git a/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java b/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java index d7afa5e6..98d23ad3 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java +++ b/CommonCore/SQL/src/de/steamwar/sql/YMLWrapper.java @@ -139,7 +139,7 @@ final class YMLWrapper { if (list.isEmpty()) { return Collections.emptyList(); } else { - return Collections.unmodifiableList(list.stream().map(SchematicType::fromDB).collect(Collectors.toList())); + return Collections.unmodifiableList(list.stream().map(SchematicType::fromDB).filter(Objects::nonNull).collect(Collectors.toList())); } }