finished plot command confirmation (clear, delete, unlink)

This commit is contained in:
boy0001 2015-03-07 16:22:15 +11:00
parent 972a3325e4
commit 37e638acad
14 changed files with 174 additions and 52 deletions

View file

@ -22,14 +22,17 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.CmdConfirm;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class Delete extends SubCommand {
@ -52,32 +55,39 @@ public class Delete extends SubCommand {
}
assert plot != null;
final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world);
if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
final double c = pWorld.SELL_PRICE;
if (c > 0d) {
EconHandler.depositPlayer(plr, c);
sendMessage(plr, C.ADDED_BALANCE, c + "");
}
}
if (MainUtil.runners.containsKey(plot)) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false;
}
final boolean result = PlotSquared.removePlot(loc.getWorld(), plot.id, true);
final long start = System.currentTimeMillis();
if (result) {
final boolean result2 = MainUtil.clearAsPlayer(plot, true, new Runnable() {
@Override
public void run() {
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
Runnable runnable = new Runnable() {
@Override
public void run() {
if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
final double c = pWorld.SELL_PRICE;
if (c > 0d) {
EconHandler.depositPlayer(plr, c);
sendMessage(plr, C.ADDED_BALANCE, c + "");
}
}
});
if (!result2) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
PlotSquared.removePlot(loc.getWorld(), plot.id, true);
final long start = System.currentTimeMillis();
final boolean result = MainUtil.clearAsPlayer(plot, true, new Runnable() {
@Override
public void run() {
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
}
});
if (!result) {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
}
DBFunc.delete(loc.getWorld(), plot);
}
DBFunc.delete(loc.getWorld(), plot);
} else {
MainUtil.sendMessage(plr, "Plot deletion has been denied.");
};
if (Settings.CONFIRM_DELETE) {
CmdConfirm.addPending(plr, "/plot delete " + plot.id, runnable);
}
else {
TaskManager.runTask(runnable);
}
return true;
}