From 336b22303fa5348de58230f109594f937527d6ee Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 16:55:38 +1100 Subject: [PATCH] optimizations --- .../plot/database/SQLManager.java | 8 +++--- .../plot/generator/BukkitHybridUtils.java | 1 + .../plot/util/bukkit/BukkitChunkManager.java | 25 ++++++++----------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 9a2ae8931..bea8ee590 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -802,15 +802,15 @@ public class SQLManager implements AbstractDB { } @Override - public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { + public void movePlot(Plot original, final Plot newPlot) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { - final int id = getId(world, originalPlot); + final int id = getId(original.world, original.id); final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); - stmt.setInt(1, newPlot.x); - stmt.setInt(2, newPlot.y); + stmt.setInt(1, newPlot.id.x); + stmt.setInt(2, newPlot.id.y); stmt.setInt(3, id); stmt.executeUpdate(); stmt.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 304a8ad02..da5f1714a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -11,6 +11,7 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.api.PlotAPI; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index dc5409fec..886ebbf44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -949,12 +949,12 @@ public class BukkitChunkManager extends ChunkManager { int X = chunk.getX(); int Z = chunk.getX(); Entity[] ents = chunk.getEntities(); - if (X == bx || X == tx || Z == bz || Z == tz) { - for (final Entity entity : ents) { - if (!(entity instanceof Creature)) { - continue; - } - final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); + for (final Entity entity : ents) { + if (!(entity instanceof Creature)) { + continue; + } + if (X == bx || X == tx || Z == bz || Z == tz) { + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); if (plot.id.equals(id)) { count[0]++; if (entity instanceof Animals) { @@ -964,21 +964,16 @@ public class BukkitChunkManager extends ChunkManager { count[2]++; } } - } - } - else { - for (final Entity entity : ents) { - if (!(entity instanceof Creature)) { - continue; - } - count[0]++; + } + else { + count[0]++; if (entity instanceof Animals) { count[1]++; } else { count[2]++; } - } + } } } }