Bypass forge chunk cache if it's configuratively disabled

(cherry picked from commit 9fe6385)
This commit is contained in:
cpw 2017-01-14 14:01:27 -05:00
parent d53397111b
commit 926472b359

View file

@ -470,7 +470,10 @@ public class ForgeChunkManager
return; 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; WorldServer worldServer = (WorldServer) world;
File chunkDir = worldServer.getChunkSaveLocation(); File chunkDir = worldServer.getChunkSaveLocation();
File chunkLoaderData = new File(chunkDir, "forcedchunks.dat"); File chunkLoaderData = new File(chunkDir, "forcedchunks.dat");
@ -615,7 +618,10 @@ public class ForgeChunkManager
} }
forcedChunks.remove(world); forcedChunks.remove(world);
dormantChunkCache.remove(world); if (dormantChunkCacheSize != 0) // only if in use
{
dormantChunkCache.remove(world);
}
// integrated server is shutting down // integrated server is shutting down
if (!FMLCommonHandler.instance().getMinecraftServerInstance().isServerRunning()) if (!FMLCommonHandler.instance().getMinecraftServerInstance().isServerRunning())
{ {
@ -961,6 +967,7 @@ public class ForgeChunkManager
public static void putDormantChunk(long coords, Chunk chunk) 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()); Cache<Long, Chunk> cache = dormantChunkCache.get(chunk.getWorld());
if (cache != null) if (cache != null)
{ {
@ -971,6 +978,7 @@ public class ForgeChunkManager
@Nullable @Nullable
public static Chunk fetchDormantChunk(long coords, World world) 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); Cache<Long, Chunk> cache = dormantChunkCache.get(world);
if (cache == null) if (cache == null)
{ {