Some claiming fixes

This commit is contained in:
Jesse Boyd 2017-04-20 14:12:40 +10:00
parent 47915b8b86
commit bfe98f3285
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
5 changed files with 14 additions and 15 deletions

View File

@ -141,7 +141,7 @@ public class Auto extends SubCommand {
TaskManager.IMP.sync(new RunnableVal<Object>() { TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override @Override
public void run(Object ignore) { public void run(Object ignore) {
if (value == null) { if (plot == null) {
MainUtil.sendMessage(player, C.NO_FREE_PLOTS); MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
} else { } else {
plot.claim(player, true, finalSchematic, false); plot.claim(player, true, finalSchematic, false);
@ -184,17 +184,15 @@ public class Auto extends SubCommand {
PlotId center; PlotId center;
center = new PlotId(0, 0); center = new PlotId(0, 0);
plots = Integer.MAX_VALUE; plots = Integer.MAX_VALUE;
PlotId currentId = new PlotId(0, 0); PlotId currentId;
for (int i = 0; i < plots; i++) { for (int i = 0; i < plots; i++) {
if (start == null) { if (start == null) {
start = new PlotId(0, 0); start = new PlotId(0, 0);
} else { } else {
start = start.getNextId(1); start = start.getNextId(1);
} }
currentId.x = center.x + start.x; currentId = new PlotId(center.x + start.x, center.y + start.y);
currentId.y = center.y + start.y; return currentId;
currentId.recalculateHash();
return start;
} }
return null; return null;
} }

View File

@ -84,8 +84,8 @@ public class Claim extends SubCommand {
} }
sendMessage(player, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); sendMessage(player, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
} }
plot.owner = player.getUUID();
if (plot.canClaim(player)) { if (plot.canClaim(player)) {
plot.owner = player.getUUID();
final String finalSchematic = schematic; final String finalSchematic = schematic;
DBFunc.createPlotSafe(plot, new Runnable() { DBFunc.createPlotSafe(plot, new Runnable() {
@Override @Override

View File

@ -336,14 +336,17 @@ public class SQLManager implements AbstractDB {
PreparedStatement statement = null; PreparedStatement statement = null;
UniqueStatement task = null; UniqueStatement task = null;
UniqueStatement lastTask = null; UniqueStatement lastTask = null;
for (Entry<Plot, Queue<UniqueStatement>> entry : this.plotTasks.entrySet()) { Iterator<Entry<Plot, Queue<UniqueStatement>>> iter = this.plotTasks.entrySet().iterator();
while (iter.hasNext()) {
try { try {
Entry<Plot, Queue<UniqueStatement>> entry = iter.next();
Plot plot = entry.getKey(); Plot plot = entry.getKey();
if (this.plotTasks.get(plot).isEmpty()) { Queue<UniqueStatement> tasks = entry.getValue();
this.plotTasks.remove(plot); if (tasks.isEmpty()) {
iter.remove();
continue; continue;
} }
task = this.plotTasks.get(plot).remove(); task = tasks.remove();
count++; count++;
if (task != null) { if (task != null) {
if (task.method == null || !task.method.equals(method)) { if (task.method == null || !task.method.equals(method)) {

View File

@ -2032,10 +2032,10 @@ public class Plot {
} }
try { try {
final Location loc = this.getManager().getSignLoc(this.area, this); final Location loc = this.getManager().getSignLoc(this.area, this);
ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false);
String[] lines = TaskManager.IMP.sync(new RunnableVal<String[]>() { String[] lines = TaskManager.IMP.sync(new RunnableVal<String[]>() {
@Override @Override
public void run(String[] value) { public void run(String[] value) {
ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false);
this.value = WorldUtil.IMP.getSign(loc); this.value = WorldUtil.IMP.getSign(loc);
} }
}); });

View File

@ -683,9 +683,7 @@ public abstract class PlotArea {
} else { } else {
start = start.getNextId(1); start = start.getNextId(1);
} }
currentId.x = center.x + start.x; currentId = new PlotId(center.x + start.x, center.y + start.y);
currentId.y = center.y + start.y;
currentId.recalculateHash();
Plot plot = getPlotAbs(currentId); Plot plot = getPlotAbs(currentId);
if (plot != null && plot.canClaim(player)) { if (plot != null && plot.canClaim(player)) {
setMeta("lastPlot", currentId); setMeta("lastPlot", currentId);