From d9b6204da338948d05c10fbed2c51a107250970d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 17:09:20 +1100 Subject: [PATCH] condense --- .../plot/commands/Condense.java | 16 +++++++--------- .../plot/util/bukkit/BukkitUtil.java | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index 506b6cd28..4017d85ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -27,8 +27,6 @@ import java.util.List; import java.util.Set; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.World; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -36,6 +34,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Condense extends SubCommand { public static boolean TASK = false; @@ -55,8 +54,7 @@ public class Condense extends SubCommand { return false; } final String worldname = args[0]; - final World world = Bukkit.getWorld(worldname); - if ((world == null) || !PlotSquared.isPlotWorld(worldname)) { + if (!BukkitUtil.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) { MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } @@ -90,13 +88,13 @@ public class Condense extends SubCommand { final List free = new ArrayList<>(); PlotId start = new PlotId(0, 0); while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) { - final Plot plot = MainUtil.getPlot(world, start); + final Plot plot = MainUtil.getPlot(worldname, start); if (!plot.hasOwner()) { free.add(plot.id); } start = Auto.getNextPlot(start, 1); } - MainUtil.move(world, to_move.get(0), free.get(0), new Runnable() { + MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() { @Override public void run() { if (!TASK) { @@ -107,7 +105,7 @@ public class Condense extends SubCommand { free.remove(0); int index = 0; for (final PlotId id : to_move) { - final Plot plot = MainUtil.getPlot(world, id); + final Plot plot = MainUtil.getPlot(worldname, id); if (plot.hasOwner()) { break; } @@ -118,7 +116,7 @@ public class Condense extends SubCommand { } index = 0; for (final PlotId id : free) { - final Plot plot = MainUtil.getPlot(world, id); + final Plot plot = MainUtil.getPlot(worldname, id); if (!plot.hasOwner()) { break; } @@ -138,7 +136,7 @@ public class Condense extends SubCommand { return; } sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0)); - MainUtil.move(world, to_move.get(0), free.get(0), this); + MainUtil.move(worldname, to_move.get(0), free.get(0), this); } }); TASK = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 14ed0e05d..44067676e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -38,6 +38,10 @@ public class BukkitUtil extends BlockManager { UUIDHandler.players.remove(plr); } + public static boolean isWorld(String world) { + return getWorld(world) != null; + } + public static PlotPlayer getPlayer(Player player) { if (player == lastPlayer) { return lastPlotPlayer;