/**
  * @param CommandSender $sender
  * @param string[] $args
  * @return bool
  */
 public function exec(CommandSender $sender, array $args)
 {
     if (count($args) < 2 or !is_string($args[0]) or !is_string($args[1])) {
         return false;
     }
     $clanName = Clannish::validateName($args[0], true);
     $managerName = Clannish::validateName($sender->getName());
     $memberName = Clannish::validateName($args[1]);
     $clan = Clannish::getInstance()->getClan($clanName);
     if ($clan === null) {
         $this->sendMessage($sender, "clan-not-found", ["name" => $clanName]);
         return true;
     }
     if (!($clan->getMember($managerName)->isManager() or $sender->hasPermission("clannish.operation"))) {
         $this->sendMessage($sender, "clan-manager-only");
         return true;
     }
     if (!$clan->isMember($memberName)) {
         $this->sendMessage($sender, "clan-member-not-found", ["name" => $memberName]);
         return true;
     }
     $clan->getManager()->setGrade(ClanMember::GRADE_STAFF);
     $clan->getMember($memberName)->setGrade(ClanMember::GRADE_MANAGER);
     $this->sendMessage($sender, "clan-manager-delegated", ["name" => $clanName, "member" => $memberName]);
     return true;
 }
 /**
  * @param CommandSender $sender
  * @param string[] $args
  * @return bool
  */
 public function exec(CommandSender $sender, array $args)
 {
     if (count($args) < 1 or !is_string($args[0])) {
         return false;
     }
     $clanName = Clannish::validateName($args[0], true);
     $managerName = Clannish::validateName($sender->getName());
     if (Clannish::getInstance()->isClan($clanName)) {
         $this->sendMessage($sender, "clan-already-exists", ["name" => $clanName]);
         return true;
     }
     $owningClans = Clannish::getInstance()->getOwningClans($managerName);
     if (count($owningClans) > Clannish::getInstance()->getMaximumOwningClansCount()) {
         $this->sendMessage($sender, "clan-maximum-owning-count-exceed", ["count" => Clannish::getInstance()->getMaximumOwningClansCount()]);
         return true;
     }
     Clannish::getInstance()->getClans()[] = new Clan($clanName, [new ClanMember($managerName, ["grade" => ClanMember::GRADE_MANAGER])]);
     $this->sendMessage($sender, "clan-created", ["name" => $clanName]);
     return true;
 }
 /**
  * @param CommandSender $sender
  * @param string[] $args
  * @return bool
  */
 public function exec(CommandSender $sender, array $args)
 {
     if (count($args) < 1 or !is_string($args[0])) {
         return false;
     }
     $clanName = Clannish::validateName($args[0], true);
     $managerName = Clannish::validateName($sender->getName());
     $clan = Clannish::getInstance()->getClan($clanName);
     if ($clan === null) {
         $this->sendMessage($sender, "clan-not-found", ["name" => $clanName]);
         return true;
     }
     if (!($clan->getMember($managerName)->isManager() or $sender->hasPermission("clannish.operation"))) {
         $this->sendMessage($sender, "clan-manager-only");
         return true;
     }
     $index = array_search($clan, Clannish::getInstance()->getClans());
     if ($index !== false) {
         array_splice(Clannish::getInstance()->getClans(), $index, 1);
         $this->sendMessage($sender, "clan-deleted", ["name" => $clanName]);
     }
     return true;
 }
 public function sendMessage(CommandSender $sender, $key, $format = [], $language = "")
 {
     $sender->sendMessage(Clannish::getInstance()->getMessages()->getMessage($key, $format, $language));
 }