Skip to content

Commit 50cbf8c

Browse files
committed
refactor(world): log error when world generator types are missing
1 parent 1c41cbe commit 50cbf8c

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

engine/src/main/java/org/destinationsol/world/GalaxyBuilder.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ public GalaxyBuilder(Context context, WorldConfig worldConfig) {
6363
populateSolarSystemGeneratorList();
6464
} else {
6565
for (String typeName : worldConfig.getSolarSystemGenerators()) {
66-
for (Class<? extends SolarSystemGenerator> possibleGeneratorType :
67-
moduleManager.getEnvironment().getSubtypesOf(SolarSystemGenerator.class, type -> type.getName().equals(typeName))) {
68-
solarSystemGeneratorTypes.add(possibleGeneratorType);
66+
Iterable<Class<? extends SolarSystemGenerator>> generatorTypes =
67+
moduleManager.getEnvironment().getSubtypesOf(SolarSystemGenerator.class, type -> type.getName().equals(typeName));
68+
if (!generatorTypes.iterator().hasNext()) {
69+
logger.error("Unable to find SolarSystemGenerator type {}! World generation will likely be incorrect.", typeName);
70+
continue;
71+
}
72+
73+
for (Class<? extends SolarSystemGenerator> generatorType : generatorTypes) {
74+
solarSystemGeneratorTypes.add(generatorType);
6975
}
7076
}
7177
}
@@ -74,9 +80,15 @@ public GalaxyBuilder(Context context, WorldConfig worldConfig) {
7480
populateFeatureGeneratorList();
7581
} else {
7682
for (String typeName : worldConfig.getFeatureGenerators()) {
77-
for (Class<? extends FeatureGenerator> possibleGeneratorType :
78-
moduleManager.getEnvironment().getSubtypesOf(FeatureGenerator.class, type -> type.getName().equals(typeName))) {
79-
featureGeneratorTypes.add(possibleGeneratorType);
83+
Iterable<Class<? extends FeatureGenerator>> generatorTypes =
84+
moduleManager.getEnvironment().getSubtypesOf(FeatureGenerator.class, type -> type.getName().equals(typeName));
85+
if (!generatorTypes.iterator().hasNext()) {
86+
logger.error("Unable to find FeatureGenerator type {}! World generation will likely be incorrect.", typeName);
87+
continue;
88+
}
89+
90+
for (Class<? extends FeatureGenerator> generatorType : generatorTypes) {
91+
featureGeneratorTypes.add(generatorType);
8092
}
8193
}
8294
}

0 commit comments

Comments
 (0)