forked from SteamWar/SteamWar
Fix GameModeConfig.Schematic.SubTypes
This commit is contained in:
@@ -71,11 +71,15 @@ public final class GameModeConfig<M, W> {
|
||||
}
|
||||
|
||||
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<M, W> {
|
||||
bySchematicType = new HashMap<>();
|
||||
SchematicType.values();
|
||||
DEFAULTS = SQLWrapper.impl.loadGameModeConfig(null);
|
||||
|
||||
byFileName.values().forEach(gameModeConfig -> {
|
||||
List<SchematicType> 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<M, W> {
|
||||
*/
|
||||
public final SchematicType Type;
|
||||
|
||||
private final List<String> SubTypesStrings;
|
||||
|
||||
/**
|
||||
* The schematic types that are also allowed to be chosen in this arena
|
||||
*/
|
||||
@@ -631,6 +649,7 @@ public final class GameModeConfig<M, W> {
|
||||
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");
|
||||
|
||||
@@ -139,7 +139,7 @@ final class YMLWrapper<M, W> {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user