public function onRun($currentTick) { if (count($this->plugin->storage->arenaList > 0)) { foreach ($this->plugin->storage->arenaList as $arena) { $loop = false; $block = false; if ($arena->gameState == ArenaState::WAITING) { if (count($arena->playersInArena) >= $arena->minPlayers) { $arena->gameState = ArenaState::STARTING; $arena->timer = $arena->timeInLobbyUntilStart; ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-" . $arena->timeInLobbyUntilStart); } } else { if ($arena->gameState == ArenaState::STARTING) { $arena->timer -= 1; if ($arena->timer > 0) { if ($arena->timer == 60) { ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-60"); } else { if ($arena->timer == 30) { ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-30"); } else { if ($arena->timer == 10) { ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-10"); } else { if ($arena->timer == 5) { // for (Player pl : $arena->playersInArena) { // pl.playSound(pl.getLocation(), Sound.ORB_PICKUP, 1, 0); // } ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-5"); } else { if ($arena->timer == 4) { // for (Player pl : $arena->playersInArena) { // pl.playSound(pl.getLocation(), // Sound.ORB_PICKUP, 1, 0); // } ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-4"); } else { if ($arena->timer == 3) { // for (Player pl : $arena->playersInArena) { // pl.playSound(pl.getLocation(), // Sound.ORB_PICKUP, 1, 1); // } ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-3"); } else { if ($arena->timer == 2) { // for (Player pl : $arena->playersInArena) { // pl.playSound(pl.getLocation(), // Sound.ORB_PICKUP, 1, 1); // } ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-2"); } else { if ($arena->timer == 1) { // for (Player pl : $arena->playersInArena) { // pl.playSound(pl.getLocation(), // Sound.ORB_PICKUP, 1, 2); // } ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaIsStarting"], "1-1"); } } } } } } } } } else { $arena->gameState = ArenaState::INGAME; $arena->timer = $arena->gameTime; ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["lobbyArenaStarted"], "secs-" . $arena->waitingTimeSeeker); for ($i = $arena->amountSeekersOnStart; $i > 0; $i--) { $loop = true; $seeker = mt_rand(0, count($arena->playersInArena) - 1); foreach ($arena->playersInArena as $playerCheck) { if ($this->plugin->storage->choosenSeeker[$playerCheck] != null) { if ($this->plugin->storage->choosenSeeker[$playerCheck]) { $seeker = $playerCheck; unset($this->plugin->storage->choosenSeeker[$playerCheck]); } else { if ($seeker == $playerCheck) { $i++; $loop = false; } } } } if ($loop) { if (!in_array($seeker, $arena->seekers)) { ArenaHandler::sendFMessage($arena, "%TAG%NPlayer %A%seeker%%N has been choosen as seeker!", "seeker-" . $seeker->getName()); $arena->seekers[] = $seeker; $seeker->teleport($arena->seekersWarp); $seeker . getInventory()->clearAll(); $this->plugin->storage->seekertime[$seeker] = $arena->waitingTimeSeeker; } else { $i++; } } } foreach ($arena->playersInArena as $arenaPlayer) { if (!in_array($arenaPlayer, $arena->seekers)) { $arenaPlayer->getInventory()->clearAll(); $block = $arena->disguiseBlocks[mt_rand(0, count($arena->disguiseBlocks))]; if ($this->plugin->storage->choosenBlock[$arenaPlayer] != null) { $block = $this->plugin->storage->choosenBlock[$arenaPlayer]; unset($this->plugin->storage->choosenBlock[$arenaPlayer]); } DisguiseAPI::disguiseToAll($arenaPlayer, $block->getID()); $arenaPlayer->teleport($arena->hidersWarp); $blockCount = Item::get(5); $blockCount->setDurability($block->getMaxDurability()); $arenaPlayer . getInventory()->setItem(8, $blockCount); $arenaPlayer . getInventory()->setArmorItem(0, $block); $this->plugin->storage->pBlock[$arenaPlayer] = $block; if ($block . getDurability() != 0) { MessageM::sendFMessage($arenaPlayer, "%TAG%NYou're disguised as a(n) '%A%block%%N' block.", "block-" . block . getType()->name() . replaceAll("_", "") . replaceAll("BLOCK", "") . toLowerCase() . ":" . block . getDurability()); } else { MessageM . sendFMessage($arenaPlayer, $this->plugin->storage->message->get("normal")["ingameBlock"], "block-" . $block . getType()->name() . replaceAll("_", "") . replaceAll("BLOCK", "") . toLowerCase()); } } } } } } foreach ($arena->seekers as $player) { if ($player->getInventory()->getItem(0) == null || $player->getInventory()->getItem(0)->getID() != Item::DIAMOND_SWORD) { $player->getInventory() . setItem(0, Item::DIAMOND_SWORD); $player->getInventory() . setArmorItem(0, Item::IRON_HELMET); $player->getInventory() . setArmorItem(1, Item::IRON_CHESTPLATE); $player->getInventory() . setArmorItem(2, Item::IRON_LEGGINGS); $player->getInventory() . setArmorItem(3, Item::IRON_BOOTS); //$player->playSound(player.getLocation(), Sound.ANVIL_USE, 1, 1); } if ($this->plugin->storage->seekertime[$player] != null) { $this->plugin->storage->seekertime[$player] -= 1; if ($this->plugin->storage->seekertime[$player] <= 0) { $player->teleport($arena->hidersWarp); unset($this->plugin->storage->seekertime[$player]); ArenaHandler::sendFMessage(arena, $this->plugin->storage->message->get("normal")["ingameSeekerSpawned"], "playername-" . player . getName()); } } } if ($arena->gameState == ArenaState::INGAME) { $arena->timer -= 1; if ($arena->timer > 0) { if ($arena->timer == $arena->gameTime - $arena->timeUntilHidersSword) { $sword = Item::WOOD_SWORD; //$sword->addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); foreach ($arena->playersInArena as $arenaPlayer) { if (!in_array($arenaPlayer, $arena->seekers)) { $arenaPlayer->getInventory()->addItem($sword); MessageM . sendFMessage($arenaPlayer, $this->plugin->storage->message->get("normal")["ingameGivenSword"]); } } } if ($arena->timer == 190) { ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-190"); } else { if ($arena->timer == 60) { ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-60"); } else { if ($arena->timer == 30) { ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-30"); } else { if ($arena->timer == 10) { ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-10"); } else { if ($arena->timer == 5) { //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 0); ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-5"); } else { if ($arena->timer == 4) { //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 0); ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-4"); } else { if ($arena->timer == 3) { //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 1); ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-3"); } else { if ($arena->timer == 2) { //$arena->lobbyWarp.getWorld().playSound($arena->lobbyWarp, Sound.ORB_PICKUP, 1, 1); ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-2"); } else { if ($arena->timer == 1) { $arena->lobbyWarp . getWorld() . playSound($arena->lobbyWarp, Sound . ORB_PICKUP, 1, 2); ArenaHandler::sendFMessage($arena, $this->plugin->storage->message->get("normal")["ingameArenaEnd"], "1-1"); } } } } } } } } } } else { ArenaHandler::hidersWin(arena); return; } foreach ($arena->playersInArena as $arenaPlayer) { if (!$arena->seekers . contains($arenaPlayer)) { $pLoc = new Position($arenaPlayer->getX() - 0.5, $arenaPlayer->getY(), $arenaPlayer->getZ() - 0.5, $arenaPlayer->getLevel()); $moveLoc = $this->plugin->storage->moveLoc[$arenaPlayer]; $block = $arenaPlayer->getInventory()->getItem(8); if ($block == null && $this->plugin->storage->pBlock[$arenaPlayer] != null) { $block = $this->plugin->storage->pBlock[$arenaPlayer]; $arenaPlayer->getInventory()->setItem(8, $block); } if ($moveLoc != null) { if ($moveLoc->getX() == $pLoc->getX() && $moveLoc->getY() == $pLoc->getY() && $moveLoc->getZ() == $pLoc->getZ()) { if ($block->getSize() > 1) { $block->setAmount($block->getSize() - 1); } else { $pBlock = $player->getLocation()->getBlock(); if ($pBlock->getType()->equals(Item::AIR) || $pBlock->getType()->equals(Item::WATER) || $pBlock->getType()->equals(Block::STILL_WATER)) { if ($pBlock->getType()->equals(Item::WATER) || $pBlock->getType()->equals(Item::STATIONARY_WATER)) { $this->plugin->storage->hiddenLocWater . put($player, true); } else { $this->plugin->storage->hiddenLocWater . put($player, false); } $arrayOfPlayer = array(); if (DisguiseAPI . isDisguised($player)) { DisguiseAPI . undisguiseToAll(player); $j = count($arrayOfPlayer = $this->plugin->getServer()->getgetOnlinePlayers()); for ($i = 0; $i < $j; $i++) { $pl = $arrayOfPlayer[$i]; if ($pl->getID() != $player->getID()) { $pl->hidePlayer($player); $pl->sendBlockChange($pBlock->getLocation(), $block->getType(), $block->getDurability()); } } //$block->addUnsafeEnchantment(Enchantment::DURABILITY, 10); //$player->playSound($pLoc, Sound.ORB_PICKUP, 1, 1); $this->plugin->storage->hiddenLoc[$player] = $moveLoc; MessageM . sendFMessage($player, $this->plugin->storage->message->get("normal")["ingameNowSolid"], $block->toString()); } $j = count($arrayOfPlayer = $this->plugin->getServer()->getgetOnlinePlayers()); for ($i = 0; $i < $j; $i++) { $pl = $arrayOfPlayer[$i]; if ($pl->getID() != $player->getID()) { $pl->hidePlayer($player); $pl->sendBlockChange($pBlock->getLocation(), $block->getType(), $block->getDurability()); } } } else { MessageM . sendFMessage($player, ConfigC::warning_ingameNoSolidPlace, ""); } } } else { $block->setAmount(5); if (!DisguiseAPI::isDisguised($player)) { SolidBlockHandler::makePlayerUnsolid($player); } } } } } } foreach ($arena->playersInArena as $arenaPlayer) { $arenaPlayer->setLevel($arena->timer); $arenaPlayer->setGameMode(0); } //ScoreboardHandler::updateScoreboard($arena); } $this->plugin->signsHandler->updateSigns(); } }
public static function playerJoinArena(Player $player, $arenaname) { $found = false; $alreadyJoined = false; foreach ($this->plugin->storage->{$arena}->arenaList as $arena) { if ($arena->playersInArena != null && $arena->playersInArena->contains($player)) { $alreadyJoined = true; } } if (!$alreadyJoined) { foreach ($this->plugin->storage->{$arena}->arenaList as $arena) { if (strtolower($arena->arenaname) == strtolower($arenaname)) { $found = true; if ($arena->disguiseBlocks->isEmpty()) { MessageM::sendFMessage($player, $this->plugin->getConfig()->get("error")["joinNoBlocksSet"], []); } else { $inventoryempty = true; foreach ($player->getInventory() as $invitem) { if ($invitem != null && $invitem->getID() != 0) { $inventoryempty = false; } } $localObject; $j = count($localObject = $player->getInventory()->getArmorContents()); for ($i = 0; $i < $j; $i++) { $invitem = $localObject[$i]; if ($invitem->getID() != 0) { $inventoryempty = false; } } if ($this->plugin->getConfig()->get("requireInventoryClearOnJoin") && !$inventoryempty) { MessageM::sendFMessage(player, $this->plugin->getConfig()->get("error")["joinInventoryNotEmpty"]); return; } $zero = new Position(0, 0, 0, $player->getLevel()); if ($arena->lobbyWarp != null && $arena->hidersWarp != null && $arena->seekersWarp != null && $arena->spawnWarp != null) { if (!$arena->lobbyWarp == $zero && !$arena->hidersWarp == $zero && !$arena->seekersWarp == $zero && !$arena->spawnWarp == $zero) { if ($arena->gameState == ArenaState::WAITING || $arena->gameState == ArenaState::STARTING) { if ($arena->playersInArena . size() >= $arena->maxPlayers) { if (!$player - hasPermission('blockhunt.moderator.joinfull')) { MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")["joinFull"], []); return; } } $arena->playersInArena . add(player); $pad = new PlayerArenaData($player->getLocation(), $player->getGameMode(), $player->getInventory()->getContents(), $player->getInventory()->getArmorContents(), $player->getExp(), $player->getLevel(), $player->getHealth(), $player->getFoodLevel(), $player->getActivePotionEffects(), $player->getAllowFlight()); $this->plugin->storage->pData[] = array($player, $pad); $player->teleport($arena->lobbyWarp); $player->setGameMode(0); // $localObject = $player->getActivePotionEffects().iterator(); // while (((Iterator)localObject).hasNext()) // { // PotionEffect pe = (PotionEffect)((Iterator)localObject).next(); // $player->removePotionEffect(pe.getType()); // } $player->setFoodLevel(20); $player->setHealth(20); $player->setLevel($arena->timer); $player->setExp(0.0); $player->getInventory()->clearAll(); $player->getInventory()->setHelmet(Item::AIR); $player->getInventory()->setChestplate(Item::AIR); $player->getInventory()->setLeggings(Item::AIR); $player->getInventory()->setBoots(Item::AIR); $player->setFlying(false); $player->setAllowFlight(false); if ($this->plugin->getConfig()->get("shop")["blockChooserv1Enabled"] && ($this->plugin->storage->shop->get($player->getName() . ".blockchooser") != null || $player - hasPermission('blockhunt.admin.blockchooser'))) { $shopBlockChooser = new Item($this->plugin->getConfig()->get("shop")["blockChooserv1IDname"], 0, 1, MessageM::replaceAll($this->plugin->getConfig()->get("shop")["blockChooserv1Name"])); $player->getInventory()->addItem($shopBlockChooser); } if ($this->plugin->getConfig()->get("shop")["BlockHuntPassv2Enabled"] && $this->plugin->storage->shop . get($player->getName() . ".blockhuntpass") != 0) { $shopBlockHuntPass = new Item($this->plugin->getConfig()->get("shop")["BlockHuntPassv2IDName"], 0, 1, MessageM::replaceAll($this->plugin->getConfig()->get("shop")["BlockHuntPassv2Name"])); $player->getInventory() . addItem($shopBlockHuntPass); } $player->updateInventory(); DisguiseAPI . undisguiseToAll(player); sendFMessage($arena, $this->plugin->storage->message->get("normal")["joinJoinedArena"], ["playername-" . $player->getName(), "1-" . count($arena->playersInArena), "2-" . $arena->maxPlayers]); if (count($arena->playersInArena) < $arena->minPlayers) { sendFMessage($arena, $this->plugin->getConfig()->get("warning")["lobbyNeedAtleast"], ["1-" . $arena->minPlayers]); } } else { MessageM::sendFMessage($player, $this->plugin->storage->messages->get("error")["joinArenaIngame"], []); } } else { MessageM::sendFMessage($player, $this->plugin->storage->messages->get("error")["joinWarpsNotSet"], []); } } else { MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")["joinWarpsNotSet"], []); } } } } } else { MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")['joinAlreadyJoined'], []); return; } if (!$found) { MessageM::sendFMessage(player, $this->plugin->storage->messages->get("error")["noArena"], ["name-" . $arenaname]); } SignsHandler($this->plugin)->updateSigns(); }