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