From 9b1678d22a12ba4ecedf5d83ea52394876e5d3ff Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 7 May 2015 18:15:51 +1000 Subject: [PATCH] Fixes #300 --- .../plot/PlotSquared.java | 4 ++++ .../plot/generator/BukkitHybridUtils.java | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 528ffd3a4..88c4ad300 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -94,7 +94,11 @@ public class PlotSquared { public static WorldEditPlugin worldEdit = null; private final static HashMap plotworlds = new HashMap<>(); private final static HashMap plotmanagers = new HashMap<>(); + + private static LinkedHashMap> plots; + + private static Database database; public static Connection connection; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index b1287eba0..ef3ec1090 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -186,7 +186,7 @@ public class BukkitHybridUtils extends HybridUtils { this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { - if (regions.size() == 0) { + if (regions.size() == 0 && chunks.size() == 0) { BukkitHybridUtils.UPDATE = false; PlotSquared.log(C.PREFIX.s() + "Finished road conversion"); Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task); @@ -194,12 +194,14 @@ public class BukkitHybridUtils extends HybridUtils { } else { try { if (chunks.size() < 1024) { - final ChunkLoc loc = regions.get(0); - PlotSquared.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)"); - PlotSquared.log(" - Remaining: " + regions.size()); - chunks.addAll(getChunks(regions.get(0))); - regions.remove(0); - System.gc(); + if (regions.size() > 0) { + final ChunkLoc loc = regions.get(0); + PlotSquared.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)"); + PlotSquared.log(" - Remaining: " + regions.size()); + chunks.addAll(getChunks(loc)); + regions.remove(0); + System.gc(); + } } if (chunks.size() > 0) { long diff = System.currentTimeMillis() + 25; @@ -222,7 +224,7 @@ public class BukkitHybridUtils extends HybridUtils { return; } if (System.currentTimeMillis() - last < 50) { - while (System.currentTimeMillis() < diff) { + while (System.currentTimeMillis() < diff && chunks.size() > 0) { ChunkLoc chunk = chunks.get(0); chunks.remove(0); regenerateRoad(world, chunk); @@ -232,6 +234,7 @@ public class BukkitHybridUtils extends HybridUtils { last = System.currentTimeMillis(); } } catch (final Exception e) { + e.printStackTrace(); final ChunkLoc loc = regions.get(0); PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); final int sx = loc.x << 5;