diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 99eb2cf84..cf08c81da 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1420,33 +1420,33 @@ public class PlayerEvents extends PlotListener implements Listener { return true; } } - for (IntegerFlag flag : flags) { - int i; - switch (flag.getName()) { - case "entity-cap": - i = 0; - break; - case "mob-cap": - i = 3; - break; - case "hostile-cap": - i = 2; - break; - case "animal-cap": - i = 1; - break; - case "vehicle-cap": - i = 4; - break; - case "misc-cap": - i = 5; - break; - default: - i = 0; - } - mobs[i]++; - } if (mobs != null) { + for (IntegerFlag flag : flags) { + int i; + switch (flag.getName()) { + case "entity-cap": + i = 0; + break; + case "mob-cap": + i = 3; + break; + case "hostile-cap": + i = 2; + break; + case "animal-cap": + i = 1; + break; + case "vehicle-cap": + i = 4; + break; + case "misc-cap": + i = 5; + break; + default: + i = 0; + } + mobs[i]++; + } plot.setMeta("EntityCount", mobs); plot.setMeta("EntityCountTime", System.currentTimeMillis()); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/block/GlobalBlockQueue.java b/Core/src/main/java/com/intellectualcrafters/plot/util/block/GlobalBlockQueue.java index 3980335fc..461f30b60 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/block/GlobalBlockQueue.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/block/GlobalBlockQueue.java @@ -291,7 +291,7 @@ public class GlobalBlockQueue { if (this.runnables.isEmpty()) { return false; } - final ConcurrentLinkedDeque tmp = new ConcurrentLinkedDeque<>(this.runnables); + final ArrayList tmp = new ArrayList<>(this.runnables); this.runnables.clear(); for (final Runnable runnable : tmp) { runnable.run(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java index a78ca1b5c..c75290f7f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java @@ -18,7 +18,6 @@ import com.intellectualcrafters.plot.object.RunnableVal3; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; - import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -26,9 +25,9 @@ import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Objects; -import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedDeque; public class ExpireManager { @@ -217,7 +216,7 @@ public class ExpireManager { return false; } this.running = 2; - final Set plots = PS.get().getPlots(); + final ConcurrentLinkedDeque plots = new ConcurrentLinkedDeque(PS.get().getPlots()); TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -226,14 +225,12 @@ public class ExpireManager { return; } long start = System.currentTimeMillis(); - Iterator iterator = plots.iterator(); - while (iterator.hasNext() && System.currentTimeMillis() - start < 2) { + while (!plots.isEmpty()) { if (ExpireManager.this.running != 2) { ExpireManager.this.running = 0; return; } - final Plot plot = iterator.next(); - iterator.remove(); + final Plot plot = plots.poll(); PlotArea area = plot.getArea(); final ArrayDeque applicable = new ArrayDeque<>(tasks); final Collection expired = isExpired(applicable, plot); @@ -242,7 +239,13 @@ public class ExpireManager { } for (ExpiryTask expiryTask : expired) { if (!expiryTask.needsAnalysis()) { - expiredTask.run(plot, this, expiryTask.requiresConfirmation()); + expiredTask.run(plot, new Runnable() { + @Override + public void run() { + TaskManager.IMP.taskLaterAsync(this, 1); + } + }, expiryTask.requiresConfirmation()); + return; } } final Runnable task = this; @@ -252,7 +255,12 @@ public class ExpireManager { passesComplexity(changed, expired, new RunnableVal() { @Override public void run(Boolean confirmation) { - expiredTask.run(plot, task, confirmation); + expiredTask.run(plot, new Runnable() { + @Override + public void run() { + TaskManager.IMP.taskLaterAsync(task, 1); + } + }, confirmation); } }, new Runnable() { @Override @@ -280,7 +288,7 @@ public class ExpireManager { }, new Runnable() { @Override public void run() { - task.run(); + TaskManager.IMP.taskLaterAsync(task, 1); } }); } else {