From fcc5056f8ce4474b83a8a1e615ce959e02315d97 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 18 Jul 2015 15:45:04 +1000 Subject: [PATCH] Prevent plot deletion during plot analysis --- .../plot/object/PlotAnalysis.java | 18 +++++++++++++++--- .../plot/util/ExpireManager.java | 6 ++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java b/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java index 85c004882..5df1bd032 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java @@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.TaskManager; @@ -102,19 +103,24 @@ public class PlotAnalysis { @Override public void run() { Iterator iter = plots.iterator(); - PS.log(" - $1Reducing " + plots.size() + " plots to those with sufficient data"); while (iter.hasNext()) { Plot plot = iter.next(); if (plot.settings.ratings == null || plot.settings.ratings.size() == 0) { iter.remove(); } + else { + MainUtil.runners.put(plot, 1); + } } PS.log(" - | Reduced to " + plots.size() + " plots"); if (plots.size() < 3) { PS.log("Calibration cancelled due to insufficient comparison data, please try again later"); running = false; + for (Plot plot : plots) { + MainUtil.runners.remove(plot); + } return; } @@ -327,8 +333,11 @@ public class PlotAnalysis { logln("Correlation: "); logln(getCC(n, sum(square(getSD(rank_complexity, rank_ratings))))); if (optimal_complexity == Integer.MAX_VALUE) { - PS.log(""); + PS.log("Insufficient data to determine correlation! " + optimal_index + " | " + n); running = false; + for (Plot plot : plots) { + MainUtil.runners.remove(plot); + } return; } } @@ -337,7 +346,7 @@ public class PlotAnalysis { sort(sorted); optimal_complexity = sorted[optimal_index]; logln("Complexity: "); - logln(sorted); + logln(complexity); logln("Ratings: "); logln(rank_ratings); } @@ -364,6 +373,9 @@ public class PlotAnalysis { PS.log("$1Done!"); running = false; + for (Plot plot : plots) { + MainUtil.runners.remove(plot); + } whenDone.run(); } }); diff --git a/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 92f46d9cc..00a4b8d36 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -151,6 +151,12 @@ public class ExpireManager { } } }; + if (MainUtil.runners.containsKey(plot)) { + PS.log("$2[&5Expire&dManager$2] &bSkipping plot in use: " + plot); + expiredPlots.get(world).remove(plot); + this.run(); + return; + } if (Settings.CLEAR_THRESHOLD != -1 && plotworld.TYPE == 0) { PlotAnalysis analysis = plot.getComplexity(); if (analysis != null) {