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
1 changed files with 10 additions and 2 deletions

View File

@ -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())
{
@ -961,6 +967,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)
{
@ -971,6 +978,7 @@ public class ForgeChunkManager
@Nullable
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)
{