public function work(Player $interactedPlayer)
 {
     if (FreedomDive::getInstance()->getWorldManagerByWorldFolderName($this->worldName)->canJoinGame()) {
         $interactedPlayer->teleport(Server::getInstance()->getLevelByName($this->worldName)->getSpawnLocation());
         FreedomDive::getInstance()->getWorldManagerByWorldFolderName($this->worldName)->onPlayerMoveToWorld($interactedPlayer);
     } else {
         $interactedPlayer->sendMessage(FreedomDive::getTranslation("CANNOT_JOIN"));
     }
 }
Example #2
0
 public function getTip()
 {
     switch ($this->currentStatus) {
         case self::STATUS_NOT_STARTED:
             return TextFormat::GREEN . FreedomDive::getTranslation("WAITING_FOR_PLAYERS", count($this->player), FreedomDive::getInstance()->getConfiguration("NEED_PLAYERS"));
         case self::STATUS_PREPARING:
             $time = (FreedomDive::getInstance()->getConfiguration("PREPARATION_TERM") - $this->roundTick) / 20;
             return TextFormat::GREEN . FreedomDive::getTranslation("PREPARING", round($time / 60), $time % 60);
         case self::STATUS_INGAME:
             $time = (FreedomDive::getInstance()->getConfiguration("GAME_TERM") - $this->roundTick) / 20;
             return TextFormat::AQUA . FreedomDive::getTranslation("GAME_MESSAGE", round($time / 60), $time % 60, $this->aliveCount);
         default:
             return "";
     }
 }
Example #3
0
 public function notifyGameEnded($serverId, array $winner)
 {
     if (count($winner) === 0) {
         $this->getServer()->broadcastMessage(TextFormat::AQUA . FreedomDive::getTranslation("FINISH_NO_WINNER", $serverId));
     } else {
         $winnerText = implode(", ", $winner);
         foreach ($winner as $winnerName) {
             if (isset($this->wins[$winnerName])) {
                 $this->wins[$winnerName]++;
             } else {
                 $this->wins[$winnerName] = 0;
             }
             //$winnerText .= "$winnerName, ";
         }
         arsort($this->wins);
         //$winnerText = substr($winnerText, 0, -2);
         $this->getServer()->broadcastMessage(TextFormat::AQUA . FreedomDive::getTranslation("FINISH_WINNER", $serverId, $winnerText));
         $wins = new Config($this->getDataFolder() . "wins.yml", Config::YAML);
         $wins->setAll($this->wins);
         $wins->save();
     }
 }