diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/WorldChunkUpdateManager.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/WorldChunkUpdateManager.java index 35e3cc514..adc0899f4 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/WorldChunkUpdateManager.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/chunkUpdating/WorldChunkUpdateManager.java @@ -11,6 +11,8 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapp import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collections; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; @@ -28,6 +30,9 @@ public class WorldChunkUpdateManager /** singleton since we only expect to have one world loaded at a time */ public static final WorldChunkUpdateManager INSTANCE = new WorldChunkUpdateManager(); + public static final Set LOGGED_GET_ERROR_MESSAGES = Collections.newSetFromMap(new ConcurrentHashMap()); + + /** * Queues are only removed during world shutdown. * The assumption is that there will be a limited number of {@link ILevelWrapper}'s @@ -37,6 +42,7 @@ public class WorldChunkUpdateManager + //=============// // constructor // //=============// @@ -62,6 +68,7 @@ public class WorldChunkUpdateManager AbstractDhWorld world = SharedApi.getAbstractDhWorld(); if (world == null) { + // world isn't loaded, no warnings need to be logged return null; } @@ -73,6 +80,12 @@ public class WorldChunkUpdateManager // but this check confirms it && !(levelWrapper instanceof IClientLevelWrapper)) { + String errorMessage = "Unable to find chunk update manager for level ["+levelWrapper+"]-["+levelWrapper.getClass().getName()+"], world environment: ["+world.environment+"], chunk updates may fail. This message will only be logged once."; + if (LOGGED_GET_ERROR_MESSAGES.add(errorMessage)) + { + LOGGER.warn(errorMessage); + } + return null; } else if ( @@ -81,6 +94,12 @@ public class WorldChunkUpdateManager // when hosting a server we only care about the server wrappers && !(levelWrapper instanceof IServerLevelWrapper)) { + String errorMessage = "Unable to find chunk update manager for level ["+levelWrapper+"]-["+levelWrapper.getClass().getName()+"], world environment: ["+world.environment+"], chunk updates may fail. This message will only be logged once."; + if (LOGGED_GET_ERROR_MESSAGES.add(errorMessage)) + { + LOGGER.warn(errorMessage); + } + return null; }