2014-11-08 20:27:09 +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 /
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2014-09-30 13:17:55 +02:00
|
|
|
|
|
|
|
package com.intellectualcrafters.plot.commands;
|
|
|
|
|
|
|
|
import com.intellectualcrafters.plot.C;
|
|
|
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
|
|
|
import com.intellectualcrafters.plot.Plot;
|
2014-10-23 09:23:09 +02:00
|
|
|
import com.intellectualcrafters.plot.PlotMain;
|
2014-11-08 20:27:09 +01:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.entity.Player;
|
2014-09-30 13:17:55 +02:00
|
|
|
|
2014-11-09 12:51:17 +01:00
|
|
|
@SuppressWarnings({"unused", "deprecation", "javadoc"})
|
2014-09-30 13:17:55 +02:00
|
|
|
public class Kick extends SubCommand {
|
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
public Kick() {
|
|
|
|
super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS, true);
|
|
|
|
}
|
2014-09-30 13:17:55 +02:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
@Override
|
|
|
|
public boolean execute(final Player plr, final String... args) {
|
|
|
|
if (!PlayerFunctions.isInPlot(plr)) {
|
|
|
|
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
|
|
|
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
|
|
|
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (args.length != 1) {
|
|
|
|
PlayerFunctions.sendMessage(plr, "&c/plot kick <player>");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (Bukkit.getPlayer(args[0]) == null) {
|
|
|
|
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final Player player = Bukkit.getPlayer(args[0]);
|
|
|
|
if (!player.getWorld().equals(plr.getWorld()) || !PlayerFunctions.isInPlot(player) || (PlayerFunctions.getCurrentPlot(player) == null) || !PlayerFunctions.getCurrentPlot(player).equals(plot)) {
|
|
|
|
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
player.teleport(player.getWorld().getSpawnLocation());
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-30 13:17:55 +02:00
|
|
|
}
|