2014-09-26 14:01:30 +10:00
|
|
|
/*
|
2014-10-12 00:37:36 -07:00
|
|
|
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
|
|
|
|
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
|
|
|
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
2014-11-05 14:42:08 +11:00
|
|
|
*
|
2014-10-12 00:37:36 -07:00
|
|
|
* >> File = Delete.java >> Generated by: Citymonstret at 2014-08-09 01:41
|
2014-09-26 14:01:30 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
package com.intellectualcrafters.plot.commands;
|
|
|
|
|
2014-10-08 19:31:59 +02:00
|
|
|
import net.milkbowl.vault.economy.Economy;
|
2014-10-11 00:33:10 -07:00
|
|
|
|
2014-10-08 19:31:59 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2014-09-26 14:01:30 +10:00
|
|
|
|
2014-10-11 00:33:10 -07:00
|
|
|
import com.intellectualcrafters.plot.C;
|
|
|
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
|
|
|
import com.intellectualcrafters.plot.Plot;
|
|
|
|
import com.intellectualcrafters.plot.PlotMain;
|
|
|
|
import com.intellectualcrafters.plot.PlotWorld;
|
|
|
|
import com.intellectualcrafters.plot.database.DBFunc;
|
|
|
|
|
2014-09-26 14:01:30 +10:00
|
|
|
/**
|
|
|
|
* Created by Citymonstret on 2014-08-01.
|
|
|
|
*/
|
|
|
|
public class Delete extends SubCommand {
|
|
|
|
|
2014-11-05 14:42:08 +11:00
|
|
|
public Delete() {
|
|
|
|
super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS, true);
|
|
|
|
}
|
2014-09-26 14:01:30 +10:00
|
|
|
|
2014-11-05 14:42:08 +11:00
|
|
|
@Override
|
|
|
|
public boolean execute(final Player plr, final String... args) {
|
|
|
|
if (!PlayerFunctions.isInPlot(plr)) {
|
|
|
|
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
|
|
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
|
|
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))) && !PlotMain.hasPermission(plr, "plots.admin")) {
|
|
|
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final PlotWorld pWorld = PlotMain.getWorldSettings(plot.getWorld());
|
|
|
|
if (PlotMain.useEconomy && pWorld.USE_ECONOMY) {
|
|
|
|
final double c = pWorld.SELL_PRICE;
|
|
|
|
if (c > 0d) {
|
|
|
|
final Economy economy = PlotMain.economy;
|
|
|
|
economy.depositPlayer(plr, c);
|
|
|
|
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
|
|
|
|
if (result) {
|
|
|
|
plot.clear(plr);
|
|
|
|
DBFunc.delete(plr.getWorld().getName(), plot);
|
|
|
|
if ((Math.abs(plot.id.x) <= Math.abs(Auto.lastPlot.x)) && (Math.abs(plot.id.y) <= Math.abs(Auto.lastPlot.y))) {
|
2014-10-29 17:18:17 +11:00
|
|
|
Auto.lastPlot = plot.id;
|
|
|
|
}
|
2014-11-05 14:42:08 +11:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-26 14:01:30 +10:00
|
|
|
}
|