protected function run(Session $ses, array $args)
 {
     $name = str_replace(["|", "&"], ["\n", "ยง"], implode(" ", $args));
     $ses->getPlayer()->setDisplayName($name);
     $ses->getPlayer()->setNameTag($name);
     return TextFormat::GREEN . "Your nametag has been changed to " . TextFormat::WHITE . $name . TextFormat::GREEN . ".";
 }
Example #2
0
 /**
  * @param Session $session
  * @return bool allow join
  */
 public function onJoin(Session $session)
 {
     $this->playerData[$session->getUID()] = new SpleefSessionData($this, $session);
     $session->tell("%s, welcome to Spleef.", $session->getPlayer()->getName());
     $session->teleport($spawn = Settings::spleef_spawn($this->getMain()->getServer()));
     $session->getPlayer()->setSpawn($spawn);
     if ($session->getPlayer()->getGamemode() === 2) {
         $session->getPlayer()->setGamemode(0);
     }
     return true;
 }
 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)
 {
     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])) {
         return TextFormat::RED . "Usage: " . $this->getUsage();
     }
     $lv = $this->getPlugin()->getServer()->getLevelByName(array_shift($args));
     if (!$lv instanceof Level) {
         return TextFormat::RED . "Such level doesn't exist.";
     }
     $ses->getPlayer()->teleport($lv->getSpawnLocation());
     return TextFormat::GREEN . "Teleported.";
 }
Example #6
0
 public function __construct(Session $session)
 {
     $this->session = $session;
     $this->onSince = time();
     //		$this->data = $this->session->getMain()->getMySQLi()->query(
     //			"SELECT * FROM players WHERE INSTR(names, %s);",
     //			MysqlConnection::ASSOC, $session->getPlayer()->getName() . "|");
     $isOld = is_array($this->data = $this->session->getMain()->getMySQLi()->query("SELECT * FROM players WHERE primaryname=%s;", MysqlConnection::ASSOC, strtolower($session->getPlayer()->getName())));
     if (!$isOld) {
         $session->getMain()->getStats()->increment(LegionPE::TITLE_LEGIONPE_NEW_JOINS);
     } else {
         foreach (["uid", "lastonline", "registry", "ipconfig", "notag", "lastgrind", "rank", "tid", "teamrank", "teamjointime", "warnpts"] as $key) {
             if (!isset($this->data[$key])) {
                 $this->data[$key] = 0;
             } else {
                 $this->data[$key] = (int) $this->data[$key];
             }
         }
         $this->data["coins"] = $this->lastCoins = (double) $this->data["coins"];
     }
 }
Example #7
0
 public function onMove(Session $session, PlayerMoveEvent $event)
 {
     if (Settings::parkour_isFallen($session->getPlayer())) {
         $data = $this->data[$session->getUID()];
         $session->teleport(Settings::parkour_checkpoint_startPos($data->getProgress(), $this->getMain()->getServer()));
         $data->setFalls($data->getFalls() + 1);
         $data->addTmpFalls();
     }
 }
Example #8
0
 public function giveKits(Session $session)
 {
     $this->playerData[$u = $session->getUID()]->getKitInUse()->equip($session->getPlayer()->getInventory(), $this->playerData[$u]);
 }