Exemple #1
0
 public function joinToArena(Player $p)
 {
     if ($this->game >= 1) {
         $p->sendMessage($this->msg->getMsg("already_running"));
     }
     $ev = new PlayerJoinArenaEvent($p, $this, "");
     if ($this->isArenaFull() && !$p->hasPermission("sg.arena.join.full")) {
         $ev->setMessage($this->msg->getMsg("game_full"));
         $ev->setCancelled();
     } else {
         if (!$p->hasPermission("sg.arena.join")) {
             $ev->setMessage(Messages::getMsg("no_permission_join", ["%NAME", $this->name]));
             $ev->setCancelled();
         } else {
             $ev->setMessage(Messages::getMsg("join_to_arena", ["%NAME" => $this->name]));
         }
     }
     $this->plugin->getServer()->getPluginManager()->callEvent($ev);
     if ($ev->isCancelled()) {
         return;
     }
     $this->messageArenaPlayers(str_replace(["%PLAYER", "%COUNT", "%MAXCOUNT"], [$p->getName(), count($this->getPlayers()), $this->getMaxPlayers()], $this->msg->getMsg("game_connect")));
     $this->players[strtolower($p->getName())]["ins"] = $p;
     $this->saveInventory($p);
     $p->teleport($this->getNextJoinPos($p));
 }
Exemple #2
0
 public function joinToArena(Player $p)
 {
     if ($this->game >= 1) {
         $p->sendMessage($this->msg->getMsg("already_running"));
     }
     if ($this->isArenaFull() && !$p->isOp() && !$p->hasPermission("sg.full")) {
         $p->sendMessage($this->msg->getMsg("game_full"));
         return;
     }
     $this->plugin->getServer()->getPluginManager()->callEvent($e = new PlayerJoinArenaEvent($p, $this));
     if ($e->isCancelled()) {
         return;
     }
     $this->players[strtolower($p->getName())]["ins"] = $p;
     $this->saveInv($p);
     $p->teleport($this->getNextJoinPos());
     $this->messageArenaPlayers(str_replace(["%PLAYER", "%COUNT", "%MAXCOUNT"], [$p->getName(), count($this->getPlayers()), $this->getMaxPlayers()], $this->msg->getMsg("game_connect")));
 }