From f60bac0e0e5fc129f0c0dfdd04c93c159dcd3486 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 29 Oct 2014 17:18:17 +1100 Subject: [PATCH] Fixed plot auto algorithms and also made some performance improvements --- .gitignore | 4 +- .../intellectualcrafters/plot/Metrics.java | 2 +- .../intellectualcrafters/plot/PlotMain.java | 4 + .../plot/commands/Auto.java | 103 ++++++++++++------ .../plot/commands/Delete.java | 3 + 5 files changed, 83 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 08cd04510..444077878 100644 --- a/.gitignore +++ b/.gitignore @@ -94,4 +94,6 @@ local.properties # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* .classpath -.project \ No newline at end of file +.project +/target +/plotsquared/target \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/Metrics.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/Metrics.java index 8df772230..4d38ff7ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/Metrics.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/Metrics.java @@ -326,7 +326,7 @@ public class Metrics { // enabled String pluginVersion = description.getVersion(); String serverVersion = Bukkit.getVersion(); - int playersOnline = Bukkit.getServer().getOnlinePlayers().size(); + int playersOnline = Bukkit.getServer().getOnlinePlayers().length; // END server software specific section -- all code below does not use // any code outside of this class / Java // Construct the post data diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index f73f387de..1c301f9bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -9,6 +9,7 @@ package com.intellectualcrafters.plot; import com.intellectualcrafters.plot.Logger.LogLevel; +import com.intellectualcrafters.plot.commands.Auto; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.database.*; import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; @@ -475,6 +476,9 @@ public class PlotMain extends JavaPlugin { PlotHelper.removeSign(worldobj, plot); DBFunc.delete(world, plot); removePlot(world, plot.id, true); + if (Math.abs(plot.id.x) absY) { + if (id.x > 0) { + return new PlotId(id.x, id.y + 1); + } + else { + return new PlotId(id.x, id.y - 1); + } + } + else if (absY > absX ){ + if (id.y > 0) { + return new PlotId(id.x - 1, id.y); + } + else { + return new PlotId(id.x + 1, id.y); + } + } + else { + if (id.x==id.y && id.x > 0) { + return new PlotId(id.x, id.y + step); + } + if (id.x==absX) { + return new PlotId(id.x, id.y + 1); + } + if (id.y == absY) { + return new PlotId(id.x, id.y - 1); + } + return new PlotId(id.x + 1, id.y); + } + } + public boolean isUnowned(World world, PlotId pos1, PlotId pos2) { for (int x = pos1.x; x <= pos2.x; x++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index f285e71ff..5822117a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -58,6 +58,9 @@ public class Delete extends SubCommand { if (result) { plot.clear(plr); DBFunc.delete(plr.getWorld().getName(), plot); + if (Math.abs(plot.id.x)<=Math.abs(Auto.lastPlot.x) && Math.abs(plot.id.y)<=Math.abs(Auto.lastPlot.y)) { + Auto.lastPlot = plot.id; + } } else { PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");