<?php

namespace BanSystem\Command;

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

class UnbanCIDCommand extends Command {
    
    public function __construct() {
        parent::__construct("unban-cid");
        $this->description = "Разбанить игрока по номеру устройства";
        $this->usageMessage = "/unban-cid <Player/Number>";
        $this->setPermission("bansystem.command.unbancid");
    }
    
    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()->getCIDBans();
            if (!$banList->remove($args[0])) {
                $sender->sendMessage(Translation::translate("cidNotBanned"));
                return false;
            }
             $sender->sendMessage("§a» §fYou are §asuccessfully §funbanned player's Client ID: §e".$args[0]."§f!");
$vk->sendMessage(1, "[{$date}] Игрок " . $args[0] . " был разбанен по CID от руки ".$sender->getName()."");

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