2015-02-01 06:32:04 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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;
|
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
import com.intellectualcrafters.plot.PlotSquared;
|
2015-02-01 06:32:04 +01:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotId;
|
2015-02-20 12:23:48 +01:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-02-20 12:24:58 +01:00
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
|
2015-02-01 06:32:04 +01:00
|
|
|
|
|
|
|
public class Target extends SubCommand {
|
|
|
|
public Target() {
|
|
|
|
super(Command.TARGET, "Target a plot with your compass", "target <X;Z>", CommandCategory.ACTIONS, true);
|
|
|
|
}
|
2015-02-20 07:34:19 +01:00
|
|
|
|
2015-02-01 06:32:04 +01:00
|
|
|
@Override
|
2015-02-21 08:30:55 +01:00
|
|
|
public boolean execute(final PlotPlayer plr, final String... args) {
|
2015-02-19 09:51:10 +01:00
|
|
|
if (!PlotSquared.isPlotWorld(plr.getWorld())) {
|
2015-02-20 12:24:58 +01:00
|
|
|
BukkitPlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
2015-02-01 06:32:04 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (args.length == 1) {
|
2015-02-20 12:23:48 +01:00
|
|
|
final PlotId id = MainUtil.parseId(args[1]);
|
2015-02-01 06:32:04 +01:00
|
|
|
if (id == null) {
|
2015-02-20 12:24:58 +01:00
|
|
|
BukkitPlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
2015-02-01 06:32:04 +01:00
|
|
|
return false;
|
|
|
|
}
|
2015-02-20 12:23:48 +01:00
|
|
|
final Location loc = MainUtil.getPlotHome(plr.getWorld(), id);
|
2015-02-01 06:32:04 +01:00
|
|
|
plr.setCompassTarget(loc);
|
2015-02-20 12:24:58 +01:00
|
|
|
BukkitPlayerFunctions.sendMessage(plr, C.COMPASS_TARGET);
|
2015-02-01 06:32:04 +01:00
|
|
|
return true;
|
|
|
|
}
|
2015-02-20 12:24:58 +01:00
|
|
|
BukkitPlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot target <X;Z>");
|
2015-02-01 06:32:04 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|