Improve warning logs for chunkUpdateManager
This commit is contained in:
+19
@@ -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<String> LOGGED_GET_ERROR_MESSAGES = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user