From 176baa5c0d023fccbe58415c493d5e5bb4c55859 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 13 Dec 2014 22:38:22 +1100 Subject: [PATCH] Plot unclaim / Setup command --- .../plot/commands/Delete.java | 2 +- .../plot/commands/Setup.java | 1 - .../plot/commands/Unclaim.java | 60 +++++++++---------- .../plot/config/ConfigurationNode.java | 4 +- 4 files changed, 30 insertions(+), 37 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 76e823199..49e62971c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -66,7 +66,7 @@ public class Delete extends SubCommand { Auto.lastPlot = plot.id; } } else { - PlayerFunctions.sendMessage(plr, "Plot clearing has been denied."); + PlayerFunctions.sendMessage(plr, "Plot deletion has been denied."); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 38d7e5f0d..e6555b0de 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -184,7 +184,6 @@ public class Setup extends SubCommand implements Listener { break; } } - } } if (generator == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index 20dc450d2..400ad2670 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -23,55 +23,49 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlayerFunctions; -import com.intellectualcrafters.plot.util.PlotHelper; -import org.bukkit.Bukkit; +import net.milkbowl.vault.economy.Economy; import org.bukkit.entity.Player; public class Unclaim extends SubCommand { public Unclaim() { - super(Command.UNCLAIM, "Unclaim a plot", "unclaim", CommandCategory.ACTIONS, false); + super(Command.UNCLAIM, "Unclaim a plot", "unclaim", CommandCategory.ACTIONS, true); } @Override public boolean execute(final Player plr, final String... args) { - if (plr == null) { - // Is console - if (args.length < 2) { - PlotMain.sendConsoleSenderMessage("You need to specify two arguments: ID (0;0) & World (world)"); - } else { - PlotId id = PlotId.fromString(args[0]); - String world = args[1]; - if (id == null) { - PlotMain.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]); - } else { - if (!PlotMain.isPlotWorld(world)) { - PlotMain.sendConsoleSenderMessage("Invalid plot world: " + world); - } else { - Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id); - if (plot == null) { - PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); - } else { - PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); - } - } - } - } - return true; - } - if (!PlayerFunctions.isInPlot(plr)) { - return sendMessage(plr, C.NOT_IN_PLOT); + return !sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = PlayerFunctions.getCurrentPlot(plr); if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { - return sendMessage(plr, C.UNLINK_REQUIRED); + return !sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) { - return sendMessage(plr, C.NO_PLOT_PERMS); + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))) && !PlotMain.hasPermission(plr, "plots.admin")) { + return !sendMessage(plr, C.NO_PLOT_PERMS); + } + assert plot != null; + 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) { + 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))) { + Auto.lastPlot = plot.id; + } + } else { + PlayerFunctions.sendMessage(plr, "Plot removal has been denied."); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java index b57a088b9..0f79f2d0e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java @@ -79,8 +79,8 @@ public class ConfigurationNode { } public Object getDefaultValue() { - if (this.default_value instanceof String[]) { - return StringUtils.join((String[]) this.default_value, ","); + if (this.default_value instanceof Object[]) { + return StringUtils.join((Object[]) this.default_value, ","); } return this.default_value; }