From d0d7fb2ae8c54dad52411b1a358afc6ea18b60c4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 28 Feb 2015 13:09:23 +1100 Subject: [PATCH] Move is no longer debug --- .../plot/commands/Move.java | 42 ++++++++++++------- .../intellectualcrafters/plot/config/C.java | 5 +++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index b16af7d2b..e71443ea6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -20,9 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; /** * Created 2014-08-01 for PlotSquared @@ -31,38 +35,46 @@ import com.intellectualcrafters.plot.util.MainUtil; */ public class Move extends SubCommand { public Move() { - super("debugmove", "plots.admin", "plot moving debug test", "debugmove", "move", CommandCategory.DEBUG, true); + super("debugmove", "plots.move", "Move a plot", "move", "", CommandCategory.ACTIONS, true); } @Override public boolean execute(final PlotPlayer plr, final String... args) { - if (plr == null) { - MainUtil.sendMessage(plr, "MUST BE EXECUTED BY PLAYER"); - } - if (args.length != 2) { - MainUtil.sendMessage(plr, "/plot move "); + if (args.length < 1) { + MainUtil.sendMessage(plr, C.NEED_PLOT_ID); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); return false; } - final String world = plr.getLocation().getWorld(); - final PlotId plot1 = MainUtil.parseId(args[0]); + final Location loc = plr.getLocation(); + final Plot plot1 = MainUtil.getPlot(loc); + if (plot1 == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } + if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN)) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); + return false; + } + final String world = loc.getWorld(); final PlotId plot2 = MainUtil.parseId(args[1]); - if ((plot1 == null) || (plot2 == null)) { - MainUtil.sendMessage(plr, "INVALID PLOT ID\n/plot move "); + if ((plot2 == null)) { + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); return false; } - if (plot1 == plot2) { - MainUtil.sendMessage(plr, "DUPLICATE ID"); + if (plot1.id.equals(plot2)) { + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); return false; } - if (MainUtil.move(world, plot1, plot2, new Runnable() { + if (MainUtil.move(world, plot1.id, plot2, new Runnable() { @Override public void run() { - MainUtil.sendMessage(plr, "MOVE SUCCESS"); + MainUtil.sendMessage(plr, C.MOVE_SUCCESS); } })) { return true; } else { - MainUtil.sendMessage(plr, "MOVE FAILED"); + MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED); return false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 0ff5ed8b6..039842e88 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -35,6 +35,11 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation; * @author Citymonstret */ public enum C { + /* + * Move + */ + MOVE_SUCCESS("$4Successfully moved plot."), + REQUIRES_UNOWNED("$2The location specified is already occupied."), /* * Compass */