Ejemplo n.º 1
0
 public function getMaskLocation(Player $player)
 {
     // always return player current location if there is an error
     if (!$this->maskLoc) {
         return $player->getLocation();
     }
     if (!preg_match('#^((\\?spawn\\?)|((\\-)?[0-9]+,(\\-)?[0-9]+,(\\-)?[0-9]+))@([^/\\\\]+)$#', $this->maskLocPos, $match)) {
         return $player->getLocation();
     }
     $pos = $match[1];
     $world = $match[7];
     $level = $player->getLevel();
     if ($world === "?default?") {
         $level = $player->getServer()->getDefaultLevel();
     } elseif ($world !== "?current?") {
         $level = $player->getServer()->getLevelByName($world);
         if (!$level instanceof Level) {
             $level = $player->getLevel();
         }
     }
     if ($pos === "?spawn?") {
         $position = $level->getSpawnLocation();
     } else {
         list($x, $y, $z) = explode(",", $pos);
         $position = new Position((int) $x, (int) $y, (int) $z, $level);
     }
     return $position;
 }
Ejemplo n.º 2
0
 public function getLocation()
 {
     return $this->player->getLocation();
 }
Ejemplo n.º 3
0
 public function addSpawn(Player $player)
 {
     $this->getLevelConfig();
     $location = $player->getLocation();
     $lobby = strtolower($player->getLevel()->getName());
     if ($this->level->getNested($lobby . ".spawns") !== null) {
         $spawns = $this->level->getNested($lobby . ".spawns");
         $count = count(array_keys($spawns));
     } else {
         $count = 0;
     }
     $this->level->setNested($lobby . ".spawns." . $count, array("x" => round($location->getFloorX(), 0), "y" => round($location->getFloorY(), 0), "z" => round($location->getFloorZ(), 0)));
     $this->setLevelConfig();
     $player->sendMessage(TextFormat::GREEN . "Spawn set");
     return true;
 }
Ejemplo n.º 4
0
 public function touch(Player $damager, Player $entity)
 {
     $damagerGameId = $this->players[$damager->getName()];
     $entityGameId = $this->players[$entity->getName()];
     if ($damagerGameId === $entityGameId && $damagerGameId !== "NONE") {
         $returnVal = $this->games[$damagerGameId]->touch($damager->getName(), $entity->getName());
         switch ($returnVal) {
             case GameManager::RETURNTYPE_TOUCH_ALREADY_TOUCED_FAILED:
                 $damager->sendMessage(TextFormat::RED . $this->getTranslation("TOUCH_ALREADY_TOUCHED"));
                 break;
             case GameManager::RETURNTYPE_TOUCH_IN_PREPARATION_OR_REST_FAILED:
                 $damager->sendMessage(TextFormat::RED . $this->getTranslation("PREPARATION_OR_REST"));
                 break;
             case GameManager::RETURNTYPE_TOUCH_SUCCEED:
                 $this->notifyTipForPlayers($damagerGameId, TextFormat::DARK_PURPLE . $this->getTranslation("TOUCH_MESSAGE", $damager->getName(), $entity->getName()));
                 $this->notifyForPlayers($damagerGameId, TextFormat::DARK_PURPLE . $this->getTranslation("TOUCH_MESSAGE", $damager->getName(), $entity->getName()));
                 $this->createTouchEffect($entity->getLocation(), $entity->getEyeHeight(), $damager->getLocation(), $damager->getEyeHeight());
                 break;
         }
         return $returnVal;
     }
     return false;
 }