package net.sacredlabyrinth.phaed.simpleclans.commands;
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
import net.sacredlabyrinth.phaed.simpleclans.Helper;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.text.MessageFormat;
import net.sacredlabyrinth.phaed.simpleclans.api.UUIDMigration;
/**
*
* @author phaed
*/
public class UnbanCommand
{
public UnbanCommand()
{
}
/**
* Execute the command
* @param player
* @param arg
*/
public void execute(Player player, String[] arg)
{
SimpleClans plugin = SimpleClans.getInstance();
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.ban"))
{
if (arg.length == 1)
{
String banned = arg[0];
if (plugin.getSettingsManager().isBanned(banned))
{
Player pl;
if (SimpleClans.getInstance().hasUUID())
{
pl = Helper.matchOnePlayer(UUIDMigration.getForcedPlayerUUID(banned));
} else
{
pl = Helper.matchOnePlayer(banned);
}
if (pl != null)
{
ChatBlock.sendMessage(pl, ChatColor.AQUA + plugin.getLang("you.have.been.unbanned.from.clan.commands"));
}
plugin.getSettingsManager().removeBanned(banned);
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.removed.from.the.banned.list"));
}
else
{
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.not.banned"));
}
}
else
{
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.ban.unban"), plugin.getSettingsManager().getCommandClan()));
}
}
else
{
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
}
}
}