From bfe98f328589ee761a774ecaba32c904f79a876e Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 20 Apr 2017 14:12:40 +1000 Subject: [PATCH] Some claiming fixes --- .../com/intellectualcrafters/plot/commands/Auto.java | 10 ++++------ .../com/intellectualcrafters/plot/commands/Claim.java | 2 +- .../plot/database/SQLManager.java | 11 +++++++---- .../com/intellectualcrafters/plot/object/Plot.java | 2 +- .../intellectualcrafters/plot/object/PlotArea.java | 4 +--- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 098923bdb..4e9a9b925 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -141,7 +141,7 @@ public class Auto extends SubCommand { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object ignore) { - if (value == null) { + if (plot == null) { MainUtil.sendMessage(player, C.NO_FREE_PLOTS); } else { plot.claim(player, true, finalSchematic, false); @@ -184,17 +184,15 @@ public class Auto extends SubCommand { PlotId center; center = new PlotId(0, 0); plots = Integer.MAX_VALUE; - PlotId currentId = new PlotId(0, 0); + PlotId currentId; for (int i = 0; i < plots; i++) { if (start == null) { start = new PlotId(0, 0); } else { start = start.getNextId(1); } - currentId.x = center.x + start.x; - currentId.y = center.y + start.y; - currentId.recalculateHash(); - return start; + currentId = new PlotId(center.x + start.x, center.y + start.y); + return currentId; } return null; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 019882d0a..0d8879382 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -84,8 +84,8 @@ public class Claim extends SubCommand { } sendMessage(player, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); } - plot.owner = player.getUUID(); if (plot.canClaim(player)) { + plot.owner = player.getUUID(); final String finalSchematic = schematic; DBFunc.createPlotSafe(plot, new Runnable() { @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 58b073ead..6e82443fe 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -336,14 +336,17 @@ public class SQLManager implements AbstractDB { PreparedStatement statement = null; UniqueStatement task = null; UniqueStatement lastTask = null; - for (Entry> entry : this.plotTasks.entrySet()) { + Iterator>> iter = this.plotTasks.entrySet().iterator(); + while (iter.hasNext()) { try { + Entry> entry = iter.next(); Plot plot = entry.getKey(); - if (this.plotTasks.get(plot).isEmpty()) { - this.plotTasks.remove(plot); + Queue tasks = entry.getValue(); + if (tasks.isEmpty()) { + iter.remove(); continue; } - task = this.plotTasks.get(plot).remove(); + task = tasks.remove(); count++; if (task != null) { if (task.method == null || !task.method.equals(method)) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 6cb9ea1f9..9e850ebbe 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -2032,10 +2032,10 @@ public class Plot { } try { final Location loc = this.getManager().getSignLoc(this.area, this); - ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false); String[] lines = TaskManager.IMP.sync(new RunnableVal() { @Override public void run(String[] value) { + ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false); this.value = WorldUtil.IMP.getSign(loc); } }); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index a6254be52..aea9cc6a1 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -683,9 +683,7 @@ public abstract class PlotArea { } else { start = start.getNextId(1); } - currentId.x = center.x + start.x; - currentId.y = center.y + start.y; - currentId.recalculateHash(); + currentId = new PlotId(center.x + start.x, center.y + start.y); Plot plot = getPlotAbs(currentId); if (plot != null && plot.canClaim(player)) { setMeta("lastPlot", currentId);