/** * * @param GameLevelModel $lv * @param Player $player * @return boolean */ public function portalEnter(HungerGamesPlugIn $plugin, GameLevelModel $lv, Player $player) { if ($player->getLevel()->getName() != $lv->levelName) { return true; } if ($lv->insideLevelEntracePortal($player->getPosition())) { if (!isset($this->joinedPlayers[$player->getName()])) { if ($plugin->storyenforceaccess && $lv->type != 1) { $w = $plugin->storyManager->hasPlayerWonLevel($player->getName(), $lv->type - 1); if (!$w) { $player->sendMessage(TextFormat::RED . "[HG Story Mode Enabled]"); $player->sendMessage(TextFormat::YELLOW . "Required " . TextFormat::GOLD . "WIN " . TextFormat::YELLOW . "previous level before play this level!"); $player->getLevel()->addSound(new LaunchSound($player->getPosition()), array($player)); if ($player->isOp()) { $player->sendMessage(TextFormat::AQUA . "[Admin BY-PASS Story Mode Checking]"); } else { $player->teleport($lv->enterpos); return; } } } $this->joinedPlayers[$player->getName()] = $player; $message = TextFormat::GRAY . "[HG] [" . TextFormat::AQUA . $player->getName() . TextFormat::GRAY . "] joined " . $lv->displayName . " [" . TextFormat::GREEN . count($lv->joinedPlayers) . TextFormat::GRAY . " |" . TextFormat::WHITE . "minimal " . TextFormat::YELLOW . $lv->minPlayers . TextFormat::GRAY . "]"; $player->getServer()->broadcastMessage($message, $this->joinedPlayers); $lv->level->addSound(new DoorSound($player->getPosition()), $lv->joinedPlayers); $effect = MagicUtil::addEffect($player, Effect::STRENGTH); if ($effect != null) { $this->playersWithEffects[$player->getName()] = $effect; } if (!$player->isOp()) { if (!$player->isSurvival()) { $player->setGamemode(Player::SURVIVAL); } } $player->sendMessage(TextFormat::YELLOW . "[HG] Please wait here"); $player->sendMessage(TextFormat::GRAY . "[HG] The game auto start with minimal players"); } } else { if (isset($this->joinedPlayers[$player->getName()])) { $message = TextFormat::GRAY . "[ " . $player->getName() . " ] left " . $lv->displayName; $player->getServer()->broadcastMessage($message, $this->joinedPlayers); $lv->level->addSound(new DoorSound($player), $lv->joinedPlayers); unset($this->joinedPlayers[$player->getName()]); if (count($this->joinedPlayers) < $lv->minPlayers) { $lv->joinDownCounter = $lv->joinDownCounterReset; } foreach ($plugin->arenaManager->arenas as &$arena) { if ($arena instanceof MapArenaModel) { if (isset($arena->votedPlayers[$player->getName()])) { unset($arena->votedPlayers[$player->getName()]); if ($arena->vote >= 1) { $arena->vote--; } break; } } } if (isset($this->playersWithEffects[$player->getName()])) { $effect = $this->playersWithEffects[$player->getName()]; if ($effect != null) { $player->removeEffect($effect->getId()); unset($this->playersWithEffects[$player->getName()]); } } } } }
public function preloadArenas() { $path = $this->plugin->getDataFolder() . GameLevelModel::DIR_LEVEL_DATA; if (!file_exists($path)) { @mkdir($path, 0755, true); foreach ($this->plugin->getResources() as $resource) { if (!$resource->isDir()) { $fp = $resource->getPathname(); if (strpos($fp, "level_data") != false) { $this->plugin->info(TextFormat::AQUA . " *** setup default [LEVEL Data]: " . $resource->getFilename()); copy($resource->getPathname(), $path . $resource->getFilename()); } } } } $this->levels = GameLevelModel::preloadLevels($this->plugin); $this->levelsBackup = $this->levels; }