public function onRun(Session $session, array $args)
 {
     if (!$session->getTeam() instanceof Team) {
         return TextFormat::RED . "You aren't in a team!";
     }
     if (!isset($args[0])) {
         return TextFormat::RED . "Usage: " . $this->getUsage();
     }
     $kicked = $this->getSession(array_shift($args));
     if (!$kicked instanceof Session) {
         return TextFormat::RED . "There is no player online by that name.";
     }
     if ($kicked === $session) {
         return TextFormat::RED . "You can't kick yourself from your team!\n" . TextFormat::AQUA . "Use " . TextFormat::LIGHT_PURPLE . "/team rank" . TextFormat::AQUA . " instead.";
     }
     if ($kicked->getTeam() !== $session->getTeam()) {
         return TextFormat::RED . "{$kicked} is not in your team.";
     }
     if ($session->getTeamRank() < Team::RANK_CO_LEADER) {
         return TextFormat::RED . "You must be at least a Co-Leader to kick a team member.";
     }
     if ($kicked->getTeamRank() >= $session->getTeamRank()) {
         return TextFormat::RED . "You can only kick team members of lower rank than you.";
     }
     $session->getTeam()->quit($kicked);
     $session->getPlayer()->kick(TextFormat::YELLOW . "You have been kicked from your team. You are kicked from the server to apply the changes.", false);
     return "{$session} has been kicked from the team.";
 }
 protected function onRun(Session $ses, array $args)
 {
     $team = $ses->getTeam();
     if (!$team instanceof Team) {
         return TextFormat::RED . "You are not in a team!";
     }
     if (!$ses->quitTeamConfirmed) {
         $ses->quitTeamConfirmed = true;
         return TextFormat::YELLOW . "Are you sure to quit your team? You may not be able to join the team again! If you are the leader, you are going to disband the team! Run \"/team q\" again to confirm.";
     }
     $ses->quitTeamConfirmed = false;
     if ($ses->getTeamRank() === Team::RANK_LEADER) {
         $team->tell(TextFormat::YELLOW . "Team {$team} is disbanding because the leader is quitting the team! You are going to be kicked to apply the changes.");
         /** @var Session $ses */
         foreach ($team->getSessionsOnline() as $ses) {
             $team->quit($ses);
             $ses->getPlayer()->kick(TextFormat::YELLOW . "Your team has been disbanded. You have been kicked to apply the changes", false);
         }
         $this->main->getMySQLi()->query("UPDATE PLAYERS SET tid=-1,teamrank=0,teamjointime=0 WHERE tid={$team->tid}", MysqlConnection::RAW);
         $this->main->getTeamManager()->rmTeam($team);
         return null;
     }
     $team->quit($ses);
     $ses->getPlayer()->kick(TextFormat::YELLOW . "You have quitted your team. You have been kicked to apply the changes.", false);
     return null;
 }
 protected function onRun(Session $ses, array $args)
 {
     $team = $ses->getTeam();
     if (!$team instanceof Team) {
         return TextFormat::RED . "You are not in a team!";
     }
     if (!isset($args[0])) {
         return TextFormat::RED . "Usage: " . $this->getUsage();
     }
     $target = $this->getSession(array_shift($args));
     if (!$target instanceof Session) {
         return TextFormat::RED . "There is no player online by that name!";
     }
     if (!isset($team->members[$target->getUID()])) {
         return TextFormat::RED . $target->getRealName() . " is not in your team!";
     }
     $myRank = $ses->getTeamRank();
     $lightPurple = TextFormat::LIGHT_PURPLE;
     $red = TextFormat::RED;
     $aqua = TextFormat::AQUA;
     if ($myRank < Team::RANK_CO_LEADER) {
         return $red . "You must be{$lightPurple} a team leader or co-leader{$red} to promote/demote players!";
     }
     $hisRank = $ses->getTeamRank();
     if ($hisRank === Team::RANK_CO_LEADER and $this->promote) {
         return TextFormat::RED . "There can only be one leader per team, and the leadership cannot be transferred. \n{$aqua}" . "You can contact an{$lightPurple} admin{$aqua}, a{$lightPurple} developer{$aqua} or an{$lightPurple} owner{$aqua} if you have special reasons.";
     }
     if ($hisRank === Team::RANK_JUNIOR and !$this->promote) {
         return TextFormat::RED . "Junior-Member is already the lowest rank. \n{$aqua}" . "Use {$lightPurple}/t k{$aqua} if you wish to kick the player.";
     }
     if ($hisRank >= $myRank) {
         return TextFormat::RED . "You can only promote/demote members of lower rank than you!";
     }
     $team->members[$target->getUID()] = $target->getMysqlSession()->data["teamrank"] = $this->promote ? ++$hisRank : --$hisRank;
     $rankName = Team::$RANK_NAMES[$hisRank];
     $target->tell(TextFormat::AQUA . "You have been " . $this->getName() . "d to a{$lightPurple} {$rankName}{$aqua} by " . $ses->getRealName() . ". \n" . TextFormat::GREEN . "If you wish to have your nametag updated, please rejoin.\n{$aqua}" . "If you don't mind, you don't need to rejoin; your nametag will be updated the next time you join.");
     // TODO $session->recalculateNametag()
     return TextFormat::GREEN . $target->getRealName() . " has been " . $this->getName() . "d to a{$lightPurple} {$rankName}.";
 }
 protected function onRun(Session $ses, array $args)
 {
     if (!($team = $ses->getTeam()) instanceof Team) {
         return TextFormat::RED . "You aren't in a team!";
     }
     if ($ses->getTeamRank() < Team::RANK_CO_LEADER) {
         return TextFormat::RED . "You must be a leader or a co-leader to change the state of your team!";
     }
     if ($team->open === $this->open) {
         return TextFormat::RED . "Your team is already a " . TextFormat::LIGHT_PURPLE . ($this->open ? "open" : "closed") . TextFormat::GREEN . " team!";
     }
     $team->open = $this->open;
     return TextFormat::GREEN . "Your team is now a " . TextFormat::LIGHT_PURPLE . ($this->open ? "open" : "closed") . TextFormat::GREEN . " team.";
 }