protected function onRun(Session $ses, array $args)
 {
     if (!isset($args[0])) {
         return TextFormat::RED . "Usage: " . $this->getUsage();
     }
     if ($ses->getTeam() instanceof Team) {
         return TextFormat::RED . "You are alerady in a team!";
     }
     $name = array_shift($args);
     if (preg_match('#^[A-Za-z][A-Za-z0-9_\\-]{2,62}$#', $name) === 0) {
         $red = TextFormat::RED;
         $yellow = TextFormat::YELLOW;
         $aqua = TextFormat::AQUA;
         return $red . "A team name must{$yellow} start with an alphabet{$red}, must{$yellow} only contain{$aqua} alphabets{$red},{$aqua} numerals{$red},{$aqua} underscore{$red} and{$aqua} hyphens{$red}, must be{$yellow} at least 3 characters{$red} long and{$yellow} at most 63 characters{$red} long.";
     }
     if ($this->main->getTeamManager()->getTeamByExactName($name) instanceof Team) {
         return TextFormat::RED . "A team with this name already exists!";
     }
     $team = new Team($this->main, $this->main->getMySQLi()->nextTID(), $name, Settings::team_maxCapacity($ses->getRank()), false, [$ses->getUID() => Team::RANK_LEADER]);
     $ses->getMysqlSession()->data["tid"] = $team->tid;
     $ses->getMysqlSession()->data["teamrank"] = Team::RANK_LEADER;
     $ses->getMysqlSession()->data["teamjointime"] = time();
     $this->main->getTeamManager()->addTeam($team);
     $ses->getPlayer()->kick(TextFormat::YELLOW . "You have been kicked from the server in order to apply your changes about creating a team.", false);
     return null;
 }
Example #2
0
 public function formatChat(Session $session, $msg, $isACTION)
 {
     $tag = "";
     if (isset($this->data[$uid = $session->getUID()]) and ($completions = $this->data[$uid]->getCompletions()) > 0) {
         $tag = "[§e" . $completions . "§7]";
     }
     $color = $session->getRank() & (Settings::RANK_SECTOR_IMPORTANCE | Settings::RANK_SECTOR_PERMISSION) & ~Settings::RANK_IMPORTANCE_TESTER ? "§f" : "";
     return $isACTION ? "* {$tag}{$session} {$color}{$msg}" : "{$tag}{$session}: {$color}{$msg}";
 }
Example #3
0
 public function __construct(Session $session)
 {
     $this->ses = $session;
     $this->bypass = ($session->getRank() & Settings::RANK_PERM_SPAM) > 0;
 }
Example #4
0
 protected function checkPerm(Session $session)
 {
     return $session->getRank() > 0;
 }
Example #5
0
 public function havingMaxKits()
 {
     return count($this->kits) >= Settings::kitpvp_maxKits($this->session->getRank());
 }
Example #6
0
 public function checkPerm(Session $ses)
 {
     return ($ses->getRank() & Settings::RANK_PERM_DEV) === Settings::RANK_PERM_DEV;
 }
Example #7
0
 private function onListFriendCommand(Session $session)
 {
     $rank = $session->getRank();
     $max = Settings::kitpvp_maxFriends($rank);
     $uid = $session->getUID();
     $query = "SELECT(SELECT primaryname FROM players WHERE uid=IF(kitpvp_friends.smalluid={$uid},kitpvp_friends.largeuid, kitpvp_friends.smalluid))AS primaryname FROM kitpvp_friends WHERE type=%d AND(smalluid={$uid} OR largeuid={$uid});";
     $friends = $this->main->getMySQLi()->query($query, MysqlConnection::ALL, self::TYPE_FRIEND);
     $output = sprintf("You have %d/%d friends:\n", count($friends), $max);
     foreach ($friends as $friend) {
         $online = $this->main->getServer()->getPlayerExact($friend["primaryname"]) instanceof Player ? "online" : "offline";
         $output .= $friend["primaryname"] . " ({$online}), ";
     }
     return substr($output, 0, -2);
 }