From bee16ef331f6b11131f347655ddaa74c5d600fed Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 17 Mar 2013 23:43:11 -0500 Subject: [PATCH] Switch MCPC+ to using unloadChunkRequest - unloadChunk() seems to not clean up properly --- src/main/java/org/dynmap/bukkit/BukkitVersionHelper.java | 4 ++++ .../org/dynmap/bukkit/BukkitVersionHelperBukkitForge.java | 5 ++++- src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java | 5 +++++ src/main/java/org/dynmap/bukkit/BukkitVersionHelperMCPC.java | 4 ++++ src/main/java/org/dynmap/bukkit/NewMapChunkCache.java | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/dynmap/bukkit/BukkitVersionHelper.java b/src/main/java/org/dynmap/bukkit/BukkitVersionHelper.java index 1d2b4672..63c386e6 100644 --- a/src/main/java/org/dynmap/bukkit/BukkitVersionHelper.java +++ b/src/main/java/org/dynmap/bukkit/BukkitVersionHelper.java @@ -106,4 +106,8 @@ public abstract class BukkitVersionHelper { * Get field value from NBT compound */ public abstract Object getFieldValue(Object nbt, String field); + /** + * Unload chunk no save needed + */ + public abstract void unloadChunkNoSave(World w, int cx, int cz); } diff --git a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperBukkitForge.java b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperBukkitForge.java index 598d71ad..4b553160 100644 --- a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperBukkitForge.java +++ b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperBukkitForge.java @@ -95,5 +95,8 @@ public class BukkitVersionHelperBukkitForge extends BukkitVersionHelperGeneric { } return true; } - + @Override + public void unloadChunkNoSave(World w, int cx, int cz) { + w.unloadChunkRequest(cx, cz); + } } diff --git a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java index c2f2b4aa..5a5b9cae 100644 --- a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java +++ b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperCB.java @@ -93,4 +93,9 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric { nmst_y = getField(nms_tileentity, new String[] { "y" }, int.class); nmst_z = getField(nms_tileentity, new String[] { "z" }, int.class); } + @Override + public void unloadChunkNoSave(World w, int cx, int cz) { + w.unloadChunk(cx, cz, false, false); + } + } diff --git a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperMCPC.java b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperMCPC.java index 71b0d958..e41d15fe 100644 --- a/src/main/java/org/dynmap/bukkit/BukkitVersionHelperMCPC.java +++ b/src/main/java/org/dynmap/bukkit/BukkitVersionHelperMCPC.java @@ -88,4 +88,8 @@ public class BukkitVersionHelperMCPC extends BukkitVersionHelperGeneric { nmst_y = getField(nms_tileentity, new String[] { "m" }, int.class); nmst_z = getField(nms_tileentity, new String[] { "n" }, int.class); } + @Override + public void unloadChunkNoSave(World w, int cx, int cz) { + w.unloadChunkRequest(cx, cz); + } } diff --git a/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java b/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java index 2c2f1dd1..e00a2c64 100644 --- a/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java +++ b/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java @@ -944,7 +944,7 @@ public class NewMapChunkCache implements MapChunkCache { * while the actual in-use chunk area for a player where the chunks are managed * by the MC base server is 21x21 (or about a 160 block radius). * Also, if we did generate it, need to save it */ - w.unloadChunk(chunk.x, chunk.z, false, false); + helper.unloadChunkNoSave(w, chunk.x, chunk.z); } else if (isunloadpending) { /* Else, if loaded and unload is pending */ w.unloadChunkRequest(chunk.x, chunk.z); /* Request new unload */