Bypass forge chunk cache if it's configuratively disabled

This commit is contained in:
cpw committed 2017-01-14 14:01:27 -05:00
1 parent b0ae0be80e
commit 9fe6385e1f
1 file changed
+10 -2
@@ -470,7 +470,10 @@ public class ForgeChunkManager
return;
}
dormantChunkCache.put(world, CacheBuilder.newBuilder().maximumSize(dormantChunkCacheSize).<Long, Chunk>build());
if (dormantChunkCacheSize != 0)
{ // only put into cache if we're using dormant chunk caching
dormantChunkCache.put(world, CacheBuilder.newBuilder().maximumSize(dormantChunkCacheSize).<Long, Chunk>build());
}
WorldServer worldServer = (WorldServer) world;
File chunkDir = worldServer.getChunkSaveLocation();
File chunkLoaderData = new File(chunkDir, "forcedchunks.dat");
@@ -615,7 +618,10 @@ public class ForgeChunkManager
}
forcedChunks.remove(world);
dormantChunkCache.remove(world);
if (dormantChunkCacheSize != 0) // only if in use
{
dormantChunkCache.remove(world);
}
// integrated server is shutting down
if (!FMLCommonHandler.instance().getMinecraftServerInstance().isServerRunning())
{
@@ -959,6 +965,7 @@ public class ForgeChunkManager
public static void putDormantChunk(long coords, Chunk chunk)
{
if (dormantChunkCacheSize == 0) return; // Skip if we're not dormant caching chunks
Cache<Long, Chunk> cache = dormantChunkCache.get(chunk.getWorld());
if (cache != null)
{
@@ -968,6 +975,7 @@ public class ForgeChunkManager
public static Chunk fetchDormantChunk(long coords, World world)
{
if (dormantChunkCacheSize == 0) return null; // Don't bother with maps at all if its never gonna get a response
Cache<Long, Chunk> cache = dormantChunkCache.get(world);
if (cache == null)
{