2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2014-10-27 11:23:08 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
2014-10-27 11:23:08 +00:00
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
2014-10-27 11:23:08 +00:00
|
|
|
@CommandParameters(description = "Warns a player.", usage = "/<command> <player> <reason>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_warn extends FreedomCommand
|
2014-10-27 11:23:08 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
|
|
|
if (args.length < 2)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Player player = getPlayer(args[0]);
|
|
|
|
|
|
|
|
if (player == null)
|
|
|
|
{
|
|
|
|
playerMsg(PLAYER_NOT_FOUND);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sender instanceof Player)
|
|
|
|
{
|
|
|
|
if (player.equals(sender_p))
|
|
|
|
{
|
|
|
|
playerMsg(ChatColor.RED + "Please, don't try to warn yourself.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
if (plugin.al.isAdmin(player))
|
2014-10-27 11:23:08 +00:00
|
|
|
{
|
|
|
|
playerMsg(ChatColor.RED + "You can not warn admins");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
|
|
|
|
|
|
|
playerMsg(ChatColor.RED + "[WARNING] " + warnReason);
|
|
|
|
playerMsg(ChatColor.GREEN + "You have successfully warned " + player.getName());
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
plugin.pl.getPlayer(player).incrementWarnings();
|
2014-10-27 11:23:08 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-11-20 22:20:31 +00:00
|
|
|
}
|