mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-01-19 16:59:36 +01:00
delete
This commit is contained in:
parent
b9e2abce9f
commit
b2b4d827e8
@ -25,10 +25,13 @@ import net.milkbowl.vault.economy.Economy;
|
|||||||
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.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
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.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@ -39,11 +42,12 @@ public class Delete extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
Location loc = plr.getLocation();
|
||||||
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot == null) {
|
||||||
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.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
||||||
@ -51,18 +55,31 @@ public class Delete extends SubCommand {
|
|||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world);
|
final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world);
|
||||||
if (PlotSquared.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
|
if (PlotSquared.economy != null && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
|
||||||
final double c = pWorld.SELL_PRICE;
|
final double c = pWorld.SELL_PRICE;
|
||||||
if (c > 0d) {
|
if (c > 0d) {
|
||||||
final Economy economy = PlotSquared.economy;
|
final Economy economy = PlotSquared.economy;
|
||||||
economy.depositPlayer(plr, c);
|
EconHandler.depositPlayer(plr, c);
|
||||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final boolean result = PlotSquared.removePlot(plr.getWorld().getName(), plot.id, true);
|
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) {
|
if (result) {
|
||||||
plot.clear(plr, true);
|
boolean result2 = MainUtil.clearAsPlayer(plot, false, new Runnable() {
|
||||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!result2) {
|
||||||
|
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||||
|
}
|
||||||
|
DBFunc.delete(loc.getWorld(), plot);
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, "Plot deletion has been denied.");
|
MainUtil.sendMessage(plr, "Plot deletion has been denied.");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user