From 548fbef7d69aa852485fd6f2764302dd94bd4924 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 15 Aug 2011 19:04:02 -0500 Subject: [PATCH] Critical fix: a bizarre Bukkit bug was resulting in the fill command sometimes wiping out the chunk at 0,0, even when it never even touched that chunk. The bug is caused by World.unloadChunk() in unknown circumstances. This workaround fix causes the task to speed along faster and memory usage to grow very quickly if you're running the fill task at a high frequency, so I've increased the "too low" memory threshold to 200 MB and increased the status update frequency and memory check to every 5 seconds (instead of every 10 seconds). The status update frequency for the trim task has likewise been switched to every 5 seconds, for consistency. --- .gitignore | 3 ++- src/com/wimbli/WorldBorder/WorldFillTask.java | 14 +++++++------- src/com/wimbli/WorldBorder/WorldTrimTask.java | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 95c35ea..db162da 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /nbproject/private /build /dist -/lib/GroupManager.jar \ No newline at end of file +/lib/GroupManager.jar +/nbproject/pmd.settings \ No newline at end of file diff --git a/src/com/wimbli/WorldBorder/WorldFillTask.java b/src/com/wimbli/WorldBorder/WorldFillTask.java index e59cb3a..975710e 100644 --- a/src/com/wimbli/WorldBorder/WorldFillTask.java +++ b/src/com/wimbli/WorldBorder/WorldFillTask.java @@ -134,8 +134,8 @@ public class WorldFillTask implements Runnable if (paused) return; - // every 10 seconds or so, give basic progress report to let user know how it's going - if (Config.Now() > lastReport + 10000) + // every 5 seconds or so, give basic progress report to let user know how it's going + if (Config.Now() > lastReport + 5000) reportProgress(); // if we've made it at least partly outside the border, skip past any such chunks @@ -172,10 +172,10 @@ public class WorldFillTask implements Runnable { CoordXZ coord = storedChunks.remove(0); if (!originalChunks.contains(coord)) - world.unloadChunk(coord.x, coord.z); + world.unloadChunkRequest(coord.x, coord.z); coord = storedChunks.remove(0); if (!originalChunks.contains(coord)) - world.unloadChunk(coord.x, coord.z); + world.unloadChunkRequest(coord.x, coord.z); } // move on to next chunk @@ -257,6 +257,7 @@ public class WorldFillTask implements Runnable // for successful completion public void finish() { + this.paused = true; reportProgress(); world.save(); sendMessage("task successfully completed!"); @@ -285,7 +286,7 @@ public class WorldFillTask implements Runnable { CoordXZ coord = storedChunks.remove(0); if (!originalChunks.contains(coord)) - world.unloadChunk(coord.x, coord.z); + world.unloadChunkRequest(coord.x, coord.z); } } @@ -334,7 +335,6 @@ public class WorldFillTask implements Runnable // try to keep memory usage in check and keep things speedy as much as possible... world.save(); - server.savePlayers(); } // send a message to the server console/log and possibly to an in-game player @@ -347,7 +347,7 @@ public class WorldFillTask implements Runnable if (notifyPlayer != null) notifyPlayer.sendMessage("[Fill] " + text); - if (availMem < 100) + if (availMem < 200) { // running low on memory, auto-pause pausedForMemory = true; Config.StoreFillTask(); diff --git a/src/com/wimbli/WorldBorder/WorldTrimTask.java b/src/com/wimbli/WorldBorder/WorldTrimTask.java index a2440e2..410192f 100644 --- a/src/com/wimbli/WorldBorder/WorldTrimTask.java +++ b/src/com/wimbli/WorldBorder/WorldTrimTask.java @@ -120,8 +120,8 @@ public class WorldTrimTask implements Runnable if (paused) return; - // every 10 seconds or so, give basic progress report to let user know how it's going - if (Config.Now() > lastReport + 10000) + // every 5 seconds or so, give basic progress report to let user know how it's going + if (Config.Now() > lastReport + 5000) reportProgress(); if (regionChunks.isEmpty())