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; }
protected function run(Session $ses, array $args) { if (!isset($args[0])) { $ses->tell("Usage: /auth <option> [value]"); goto listopts; } $opt = array_shift($args); $value = array_shift($args); switch ($opt) { case "lastip": if ($value === "yes") { $ses->getMysqlSession()->data["ipconfig"] = Session::IPCONFIG_LASTIP; return "You are now going to be authenticated by your last IP OR your password."; } if ($value === "no") { $ses->getMysqlSession()->data["ipconfig"] = Session::IPCONFIG_DISABLE; return "You are now going to be authenticated by your password ONLY."; } return "Last-IP authentication is {$this->boolStr($ses->getMysqlSession()->data["ipconfig"] === Session::IPCONFIG_LASTIP)} for you."; } $ses->tell("Unknown option. Available options:"); listopts: $ses->tell("_____________________"); $ses->tell("| Option | Value |"); $ses->tell("| lastip | no / yes |"); $ses->tell("---------------------"); return "Example: /auth ip no"; }
public function quit(Session $session) { if (!isset($this->members[$session->getUID()])) { return false; } unset($this->members[$session->getUID()]); $session->getMysqlSession()->data["tid"] = -1; $session->getMysqlSession()->data["teamrank"] = 0; $session->getMysqlSession()->data["teamjointime"] = 0; return true; }
protected function run(Session $ses, array $args) { if (!isset($args[0])) { $args = ["help"]; } switch (array_shift($args)) { case "on": $ses->getMysqlSession()->data["notag"] = 0; return TextFormat::GREEN . "Chat tags have been enabled."; case "off": $ses->getMysqlSession()->data["notag"] = 1; return TextFormat::GREEN . "Chat tags have been disabled."; case "check": return TextFormat::AQUA . "Your tag is " . ($ses->getMysqlSession()->data["notag"] === 0 ? "on" : "off"); } return TextFormat::RED . "Usage: " . $this->getUsage(); }