fix(WorldGeneratorManager): null check
It does have error catching, but detecting this gives a much clearer log
than a NullPointerException and stack trace.
-// Copyright 2021 The Terasology Foundation
+// Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.world.generator.internal;
public class WorldGeneratorManager {
private static final Logger logger = LoggerFactory.getLogger(WorldGeneratorManager.class);
- private Context context;
+ private final Context context;
private ImmutableList<WorldGeneratorInfo> generatorInfo;
@@ -48,11 +48,17 @@ public void refresh() {
if (resolutionResult.isSuccess()) {
try (ModuleEnvironment tempEnvironment = moduleManager.loadEnvironment(resolutionResult.getModules(), false)) {
for (Class<?> generatorClass : tempEnvironment.getTypesAnnotatedWith(RegisterWorldGenerator.class)) {
- if (tempEnvironment.getModuleProviding(generatorClass).equals(module.getId())) {
+ Name providedBy = tempEnvironment.getModuleProviding(generatorClass);
+ if (providedBy == null) {
+ // These tend to be engine-module-is-weird cases.
+ logger.warn("{} found while inspecting {} but is not provided by any module.",
+ generatorClass, moduleId);
+ } else if (providedBy.equals(module.getId())) {
RegisterWorldGenerator annotation = generatorClass.getAnnotation(RegisterWorldGenerator.class);
if (isValidWorldGenerator(generatorClass)) {
SimpleUri uri = new SimpleUri(moduleId, annotation.id());
infos.add(new WorldGeneratorInfo(uri, annotation.displayName(), annotation.description()));
+ logger.debug("{} added from {}", uri, generatorClass);
} else {
logger.error("{} marked to be registered as a World Generator, " +
"but is not a subclass of WorldGenerator or lacks the correct constructor", generatorClass);
