This commit is contained in:
boy0001 2015-02-22 17:09:20 +11:00
parent e1bc18b009
commit d9b6204da3
2 changed files with 11 additions and 9 deletions

View File

@ -27,8 +27,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C; 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.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
public class Condense extends SubCommand { public class Condense extends SubCommand {
public static boolean TASK = false; public static boolean TASK = false;
@ -55,8 +54,7 @@ public class Condense extends SubCommand {
return false; return false;
} }
final String worldname = args[0]; final String worldname = args[0];
final World world = Bukkit.getWorld(worldname); if (!BukkitUtil.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) {
if ((world == null) || !PlotSquared.isPlotWorld(worldname)) {
MainUtil.sendMessage(plr, "INVALID WORLD"); MainUtil.sendMessage(plr, "INVALID WORLD");
return false; return false;
} }
@ -90,13 +88,13 @@ public class Condense extends SubCommand {
final List<PlotId> free = new ArrayList<>(); final List<PlotId> free = new ArrayList<>();
PlotId start = new PlotId(0, 0); PlotId start = new PlotId(0, 0);
while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) { 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()) { if (!plot.hasOwner()) {
free.add(plot.id); free.add(plot.id);
} }
start = Auto.getNextPlot(start, 1); 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 @Override
public void run() { public void run() {
if (!TASK) { if (!TASK) {
@ -107,7 +105,7 @@ public class Condense extends SubCommand {
free.remove(0); free.remove(0);
int index = 0; int index = 0;
for (final PlotId id : to_move) { for (final PlotId id : to_move) {
final Plot plot = MainUtil.getPlot(world, id); final Plot plot = MainUtil.getPlot(worldname, id);
if (plot.hasOwner()) { if (plot.hasOwner()) {
break; break;
} }
@ -118,7 +116,7 @@ public class Condense extends SubCommand {
} }
index = 0; index = 0;
for (final PlotId id : free) { for (final PlotId id : free) {
final Plot plot = MainUtil.getPlot(world, id); final Plot plot = MainUtil.getPlot(worldname, id);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
break; break;
} }
@ -138,7 +136,7 @@ public class Condense extends SubCommand {
return; return;
} }
sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0)); 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; TASK = true;

View File

@ -38,6 +38,10 @@ public class BukkitUtil extends BlockManager {
UUIDHandler.players.remove(plr); UUIDHandler.players.remove(plr);
} }
public static boolean isWorld(String world) {
return getWorld(world) != null;
}
public static PlotPlayer getPlayer(Player player) { public static PlotPlayer getPlayer(Player player) {
if (player == lastPlayer) { if (player == lastPlayer) {
return lastPlotPlayer; return lastPlotPlayer;