<?php

namespace BanSystem\Command;

use BanSystem\Translation\Translation;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\utils\TextFormat;

class UnbanIPCommand extends Command {
    
    public function __construct() {
        parent::__construct("unban-ip");
        $this->description = "Разбанить игрока по айпи адресу";
        $this->usageMessage = "/unban-ip <Player/IP>";
        $this->setPermission("bansystem.command.unbanip");
    }
    
    public function execute(CommandSender $sender, $commandLabel, array $args) {
    $date = date("d.m.y");
        if ($this->testPermissionSilent($sender)) {
            if (count($args) <= 0) {
                $sender->sendMessage(Translation::translateParams("usage", array($this)));
                return false;
            }
$vk = $sender->getServer()->getPluginManager()->getPlugin("VK");
            $banList = $sender->getServer()->getIPBans();
            if (!$banList->remove($args[0])) {
                $sender->sendMessage(Translation::translate("ipNotBanned"));
                return false;
            }
             $sender->sendMessage("§a» §fYou are §asuccessfully §funbanned player's IP: §e".$args[0]."§f!");
$vk->sendMessage(1, "[{$date}] Игрок " . $args[0] . " был разбанен по IP от руки ".$sender->getName()."");

        } else {
            $sender->sendMessage(Translation::translate("noPermission"));
        }
        return true;
    }
}