diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java index 2e4b3c640..9acbb6b34 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/C.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java @@ -53,7 +53,8 @@ public enum C { /* * Permission */ - NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"), NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED("&cAn unlink is required to do this."), + NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"), + NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED("&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE("&cYou can only unlink a mega-plot"), /* * Commands */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java index 206bc0957..458ae8859 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java @@ -34,6 +34,10 @@ public enum Command { /** * */ + UNLINK("unlink", "u"), + /** + * + */ CLEAR("clear", "clear", new CommandPermission("plots.clear")), /** * diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java index ecb8580ef..eecadf33c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java @@ -3,7 +3,7 @@ * 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. * - * >> File = Clear.java + * >> File = Delete.java * >> Generated by: Citymonstret at 2014-08-09 01:41 */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java index 913c16f47..c43208684 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.PlotMain; */ public class MainCommand implements CommandExecutor { - private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Reload(), new Merge() }; + private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Reload(), new Merge(), new Unlink() }; public static ArrayList subCommands = new ArrayList() { { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java new file mode 100644 index 000000000..872405e9e --- /dev/null +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java @@ -0,0 +1,59 @@ +/* + * 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. + * + * >> File = Unlink.java + * >> Generated by: Citymonstret at 2014-08-09 01:41 + */ + +package com.intellectualcrafters.plot.commands; + +import java.util.ArrayList; + +import org.bukkit.World; +import org.bukkit.entity.Player; + +import com.intellectualcrafters.plot.C; +import com.intellectualcrafters.plot.PlayerFunctions; +import com.intellectualcrafters.plot.Plot; +import com.intellectualcrafters.plot.PlotHelper; +import com.intellectualcrafters.plot.PlotId; +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.PlotSettings; +import com.intellectualcrafters.plot.database.DBFunc; + +/** + * Created by Citymonstret on 2014-08-01. + */ +public class Unlink extends SubCommand { + + public Unlink() { + super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS); + } + + @Override + public boolean execute(Player plr, String... args) { + if (!PlayerFunctions.isInPlot(plr)) { + PlayerFunctions.sendMessage(plr, "You're not in a plot."); + return true; + } + Plot plot = PlayerFunctions.getCurrentPlot(plr); + if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + return true; + } + if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + PlayerFunctions.sendMessage(plr, C.UNLINK_IMPOSSIBLE); + return true; + } + World world = plr.getWorld(); + ArrayList ids = PlayerFunctions.getPlotSelectionIds(world, PlayerFunctions.getBottomPlot(world, plot).id, PlayerFunctions.getTopPlot(world, plot).id); + for (PlotId id:ids) { + Plot myplot = PlotMain.getPlots(world).get(id); + myplot.settings.setMerged(new boolean[] {false, false, false, false} ); + DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged()); + } + return true; + } +}