<?php

namespace BanSystem\Command;

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

class UnmuteCommand extends Command {
    
    public function __construct() {
        parent::__construct("unmute");
        $this->description = "Разблокировать игрока в чате";
        $this->usageMessage  = "/unmute <Player>";
        $this->setPermission("bansystem.command.unmute");
    }
    
    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");

            $muteList = Manager::getNameMutes();
            if (!$muteList->isBanned($args[0])) {
                $sender->sendMessage(Translation::translate("playerNotMuted"));
                return false;
            }
            $muteList->remove($args[0]);
             $sender->sendMessage("§a» §fYou are §asuccessfully §funmuted player: §e".$args[0]."§f!");
$vk->sendMessage(1, "[{$date}] Игрок " . $args[0] . " был разблокирован в чате от руки ".$sender->getName()."");

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