public function updateSigns() { $this->plugin->storage->signs->reload(); foreach ($this->plugin->storage->signs->getAll() as $sign) { $signloc = $this->plugin->storage->signs->get($sign . ".location"); $locx = new Position($signloc->getX() - 0.5, $signloc->getY(), $signloc->getZ() - 0.5, $signloc->getLevel()); if ($locx->getBlock()->getID() == Item::SIGN_POST || $loc->getBlock()->getID() == Item::WALL_SIGN) { $signblock = $locx->getBlock(); $lines = $signblock->getLines(); if (strpos($sign, "leave")) { $signLines = $this->plugin->config->get('sign')['LEAVE']; $linecount = 0; foreach ($signLines as $line) { if ($linecount <= 3) { $signblock->setLine($linecount, MessageM::replaceAll($line)); } $linecount++; } $signblock->update(); } else { $linecount; if (strpos($sign, "shop")) { $signLines = $this->plugin->config->get('sign')['SHOP']; $linecount = 0; foreach ($signLines as $line) { if ($linecount <= 3) { $signblock->setLine($linecount, MessageM::replaceAll($line)); } $linecount++; } $signblock->update(); } else { foreach ($this->plugin->storage->arenaList as $arena) { if (substr($lines[1], -strlen($arena->arenaName)) === $arena->arenaName) { if ($arena::gameState == ArenaState::WAITING) { $signLines = $this->plugin->config->get('sign')['WAITING']; $linecount = 0; if ($signLines != null) { foreach ($signLines as $line) { if ($linecount <= 3) { $signblock->setLine($linecount, MessageM::replaceAll($line, ["arenaname-" . $arena->arenaName, "players-" . count($arena->playersInArena), "maxplayers-" . $arena->maxPlayers, "timeleft-" . $arena->timer])); } $linecount++; } } $signblock->update(); } else { if ($arena::gameState == ArenaState::STARTING) { $signLines = $this->plugin->config->get('sign')['STARTING']; $linecount = 0; if ($signLines != null) { foreach ($signLines as $line) { if (linecount <= 3) { $signblock->setLine($linecount, MessageM::replaceAll($line, ["arenaname-" . $arena->arenaName, "players-" . count($arena->playersInArena), "maxplayers-" . $arena->maxPlayers, "timeleft-" . $arena->timer])); } $linecount++; } } $signblock->update(); } else { if ($arena::gameState == ArenaState::INGAME) { $signLines = $this->plugin->config->get('sign')['INGAME']; $linecount = 0; if ($signLines != null) { foreach ($signLines as $line) { if ($linecount <= 3) { $signblock->setLine($linecount, MessageM::replaceAll($line, ["arenaname-" . $arena->arenaName, "players-" . count($arena->playersInArena), "maxplayers-" . $arena->maxPlayers, "timeleft-" . $arena->timer])); } $linecount++; } } $signblock->update(); } } } } } } } } else { removeSign($loc); } } }
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(); }