From 9a81e31cd611899ebc6f74a0ac98c9371df8d3a2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 1 Feb 2015 16:32:04 +1100 Subject: [PATCH] . --- .../plot/commands/Command.java | 1 + .../plot/commands/MainCommand.java | 2 +- .../plot/commands/Target.java | 59 +++++++++++++++++++ .../intellectualcrafters/plot/config/C.java | 4 ++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 2e008f74f..0e888c892 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -37,6 +37,7 @@ public enum Command { // ratings) // - /plot rate FLAG("flag", "f"), + TARGET("target"), CLUSTER("cluster", "clusters"), BUY("buy","b"), CREATEROADSCHEMATIC("createroadschematic"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 61fb62acd..3072b2f11 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -49,7 +49,7 @@ public class MainCommand implements CommandExecutor, TabCompleter { */ public static final String MAIN_PERMISSION = "plots.use"; - private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd()}; + private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target()}; public final static ArrayList subCommands = new ArrayList() { { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java new file mode 100644 index 000000000..a40f6ef4e --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -0,0 +1,59 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// + +package com.intellectualcrafters.plot.commands; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import com.intellectualcrafters.plot.PlotMain; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.PlayerFunctions; +import com.intellectualcrafters.plot.util.PlotHelper; + +public class Target extends SubCommand { + + public Target() { + super(Command.TARGET, "Target a plot with your compass", "target ", CommandCategory.ACTIONS, true); + } + + @Override + public boolean execute(final Player plr, final String... args) { + if (!PlotMain.isPlotWorld(plr.getWorld())) { + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + return false; + } + if (args.length == 1) { + PlotId id = PlotHelper.parseId(args[1]); + if (id == null) { + PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); + return false; + } + Location loc = PlotHelper.getPlotHome(plr.getWorld(), id); + plr.setCompassTarget(loc); + PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET); + return true; + } + PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot target "); + 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 776b2d35a..7b6f25097 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -37,6 +37,10 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation; * @author Citymonstret */ public enum C { + /* + * Compass + */ + COMPASS_TARGET("&6Successfully targeted plot with compass"), /* * Cluster */