From 2341b2b9720f65100f8dff3e2a55a69132c46b61 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 26 Feb 2015 22:00:46 +1100 Subject: [PATCH] Reduce memory usage of RegenAllRoads --- .../com/intellectualcrafters/plot/generator/HybridUtils.java | 1 + .../com/intellectualcrafters/plot/util/ChunkManager.java | 2 ++ .../plot/util/bukkit/BukkitChunkManager.java | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index af85a6e89..9f96252e1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -163,6 +163,7 @@ public abstract class HybridUtils { } } } + ChunkManager.manager.unloadChunk(world, chunk); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index abe0ca771..6e94e3656 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -23,6 +23,8 @@ public abstract class ChunkManager { } public abstract boolean loadChunk(String world, ChunkLoc loc); + + public abstract boolean unloadChunk(String world, ChunkLoc loc); public abstract List getChunkChunks(String world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 7c5297c57..93dbafc29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -778,6 +778,11 @@ public class BukkitChunkManager extends ChunkManager { return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(false); } + @Override + public boolean unloadChunk(final String world, final ChunkLoc loc) { + return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).unload(true, true); + } + public static void swapChunk(World world, Chunk pos1, Chunk pos2, RegionWrapper r1, RegionWrapper r2) { initMaps(); int relX = (r2.minX - r1.minX);