debugclear

This commit is contained in:
boy0001 2015-02-22 17:37:44 +11:00
parent bfd4a77c66
commit 528581b63b
6 changed files with 25 additions and 31 deletions

View File

@ -84,7 +84,7 @@ public class Buy extends SubCommand {
double initPrice = (double) flag.getValue(); double initPrice = (double) flag.getValue();
double price = initPrice; double price = initPrice;
final PlotId id = plot.id; final PlotId id = plot.id;
final PlotId id2 = MainUtil.getTopPlot(world, plot).id; final PlotId id2 = MainUtil.getTopPlot(plot).id;
final int size = MainUtil.getPlotSelectionIds(id, id2).size(); final int size = MainUtil.getPlotSelectionIds(id, id2).size();
final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
if (plotworld.USE_ECONOMY) { if (plotworld.USE_ECONOMY) {

View File

@ -67,7 +67,7 @@ public class Clear extends SubCommand {
if (plot == null) { if (plot == null) {
return sendMessage(plr, C.NOT_IN_PLOT); return sendMessage(plr, C.NOT_IN_PLOT);
} }
if (!MainUtil.getTopPlot(loc.getWorld(), plot).equals(MainUtil.getBottomPlot( plot))) { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot( plot))) {
return sendMessage(plr, C.UNLINK_REQUIRED); return sendMessage(plr, C.UNLINK_REQUIRED);
} }
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {

View File

@ -27,7 +27,6 @@ import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
@ -39,7 +38,6 @@ import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.AChunkManager;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
/** /**
@ -50,12 +48,11 @@ public class DebugClaimTest extends SubCommand {
super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false); super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false);
} }
@SuppressWarnings("unused")
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) { public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) {
return claimPlot(player, plot, teleport, ""); return claimPlot(player, plot, teleport, "");
} }
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) { public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic) {
// FIXME call claim event // FIXME call claim event
// boolean result = event result // boolean result = event result
boolean result = true; boolean result = true;

View File

@ -20,17 +20,15 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import org.bukkit.Bukkit;
import org.bukkit.Location;
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;
import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.generator.SquarePlotWorld;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; 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.Permissions;
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
@ -55,19 +53,18 @@ public class DebugClear extends SubCommand {
if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) { if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) {
PlotSquared.log("Invalid plot world: " + world); PlotSquared.log("Invalid plot world: " + world);
} else { } else {
final Plot plot = MainUtil.getPlot(Bukkit.getWorld(world), id); final Plot plot = MainUtil.getPlot(world, id);
if (plot == null) { if (plot == null) {
PlotSquared.log("Could not find plot " + args[0] + " in world " + world); PlotSquared.log("Could not find plot " + args[0] + " in world " + world);
} else { } else {
final World bukkitWorld = Bukkit.getWorld(world); final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id);
if (MainUtil.runners.containsKey(plot)) { if (MainUtil.runners.containsKey(plot)) {
MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); MainUtil.sendMessage(null, C.WAIT_FOR_TIMER);
return false; return false;
} }
MainUtil.runners.put(plot, 1); MainUtil.runners.put(plot, 1);
ChunkManager.regenerateRegion(pos1, pos2, new Runnable() { ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.runners.remove(plot); MainUtil.runners.remove(plot);
@ -81,26 +78,26 @@ public class DebugClear extends SubCommand {
} }
return true; return true;
} }
if (!BukkitPlayerFunctions.isInPlot(plr) || !(PlotSquared.getPlotWorld(plr.getWorld()) instanceof SquarePlotWorld)) { Location loc = plr.getLocation();
final Plot plot = MainUtil.getPlot(loc);
if (plot == null || !(PlotSquared.getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) {
return sendMessage(plr, C.NOT_IN_PLOT); return sendMessage(plr, C.NOT_IN_PLOT);
} }
final Plot plot = MainUtil.getPlot(loc); if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
return sendMessage(plr, C.UNLINK_REQUIRED); return sendMessage(plr, C.UNLINK_REQUIRED);
} }
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
return sendMessage(plr, C.NO_PLOT_PERMS); return sendMessage(plr, C.NO_PLOT_PERMS);
} }
assert plot != null; assert plot != null;
final World bukkitWorld = plr.getWorld(); final Location pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1);
final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id);
final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id);
if (MainUtil.runners.containsKey(plot)) { if (MainUtil.runners.containsKey(plot)) {
MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); MainUtil.sendMessage(null, C.WAIT_FOR_TIMER);
return false; return false;
} }
MainUtil.runners.put(plot, 1); MainUtil.runners.put(plot, 1);
ChunkManager.regenerateRegion(pos1, pos2, new Runnable() { ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
@Override @Override
public void run() { public void run() {
MainUtil.runners.remove(plot); MainUtil.runners.remove(plot);

View File

@ -333,7 +333,7 @@ public class MainUtil {
} }
count++; count++;
final PlotId bot = getBottomPlot(plot).id; final PlotId bot = getBottomPlot(plot).id;
final PlotId top = getTopPlot(world, plot).id; final PlotId top = getTopPlot(plot).id;
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
if (ownsPlots(world, plots, uuid, 0)) { if (ownsPlots(world, plots, uuid, 0)) {
final boolean result = mergePlots(world, plots, true); final boolean result = mergePlots(world, plots, true);
@ -379,7 +379,7 @@ public class MainUtil {
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) { if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) {
return false; return false;
} }
final PlotId top = getTopPlot(world, myplot).id; final PlotId top = getTopPlot(myplot).id;
if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) { if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) {
return false; return false;
} }
@ -724,7 +724,7 @@ public class MainUtil {
public static Location getPlotTopLoc(final String world, PlotId id) { public static Location getPlotTopLoc(final String world, PlotId id) {
final Plot plot = PlotSquared.getPlots(world).get(id); final Plot plot = PlotSquared.getPlots(world).get(id);
if (plot != null) { if (plot != null) {
id = getTopPlot(world, plot).id; id = getTopPlot(plot).id;
} }
final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
final PlotManager manager = PlotSquared.getPlotManager(world); final PlotManager manager = PlotSquared.getPlotManager(world);
@ -773,7 +773,7 @@ public class MainUtil {
return false; return false;
} }
final Plot pos1 = getBottomPlot(currentPlot); final Plot pos1 = getBottomPlot(currentPlot);
final Plot pos2 = getTopPlot(world, currentPlot); final Plot pos2 = getTopPlot(currentPlot);
final PlotId size = MainUtil.getSize(world, currentPlot); final PlotId size = MainUtil.getSize(world, currentPlot);
if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) {
return false; return false;
@ -967,12 +967,12 @@ public class MainUtil {
return plot; return plot;
} }
public static Plot getTopPlot(final String world, final Plot plot) { public static Plot getTopPlot(final Plot plot) {
if (plot.settings.getMerged(2)) { if (plot.settings.getMerged(2)) {
return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); return getTopPlot(PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1)));
} }
if (plot.settings.getMerged(1)) { if (plot.settings.getMerged(1)) {
return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); return getTopPlot(PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y)));
} }
return plot; return plot;
} }
@ -982,7 +982,7 @@ public class MainUtil {
if (!settings.isMerged()) { if (!settings.isMerged()) {
return new PlotId(1, 1); return new PlotId(1, 1);
} }
final Plot top = getTopPlot(world, plot); final Plot top = getTopPlot(plot);
final Plot bot = getBottomPlot(plot); final Plot bot = getBottomPlot(plot);
return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1); return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1);
} }

View File

@ -123,7 +123,7 @@ public class BukkitPlayerFunctions {
pos1 = MainUtil.getBottomPlot(plot1).id; pos1 = MainUtil.getBottomPlot(plot1).id;
} }
if (plot2 != null) { if (plot2 != null) {
pos2 = MainUtil.getTopPlot(world, plot2).id; pos2 = MainUtil.getTopPlot(plot2).id;
} }
final ArrayList<PlotId> myplots = new ArrayList<>(); final ArrayList<PlotId> myplots = new ArrayList<>();
for (int x = pos1.x; x <= pos2.x; x++) { for (int x = pos1.x; x <= pos2.x; x++) {