/** * * @param * $ticks */ public function onRun($ticks) { try { if (empty($this->lv)) { return; } $start_time = microtime(true); $k = 1; foreach ($this->lv->currentMap->livePlayers as $gamer) { $targetWorldName = $gamer->levelName . "_TEMP"; $this->lv->level->addSound(new LaunchSound($gamer->player->getPosition()), array($gamer->player)); MapPortal::teleportToMap($targetWorldName, $gamer->player); $this->lv->currentMap->enterArena($gamer); MagicUtil::addEffect($gamer->player, Effect::INVISIBILITY, 1); foreach ($this->lv->currentMap->livePlayers as $gp) { if ($gp instanceof GamePlayer) { $gamer->hidePlayerFrom($gp->player); } } $this->plugin->log("[HungerGamesLevelPlayerToArenaTask] " . $this->lv->type . " | selected map " . $targetWorldName . " TP player [" . $k++ . "]" . $gamer->player->getName() . ")"); } $this->plugin->log("[HungerGamesLevelPlayerToArenaTask: took " . (microtime(true) - $start_time)); } catch (\Exception $e) { $this->plugin->printError($e); } }
public function onPlayerInteract(PlayerInteractEvent $event) { $player = $event->getPlayer(); $block = $event->getBlock(); if ($player instanceof Player) { if (round($this->plugin->vipSignPos->x) === round($block->x) and round($this->plugin->vipSignPos->y) === round($block->y) and round($this->plugin->vipSignPos->z) === round($block->z)) { if ($this->plugin->vipenforceaccess) { $vip = $this->checkInVIP($event->getPlayer()); if (!$vip) { $message = TextFormat::YELLOW . "[HG] Require " . TextFormat::RED . "VIP+ " . TextFormat::YELLOW . "membership."; $event->getPlayer()->sendMessage($message); return; } } MapPortal::teleportingToLobby($player, $this->plugin->vipLevelName, $this->plugin->vipSpawnPos); $this->plugin->log("[HG] teleporting to VIP lodge " . $this->plugin->vipSpawnPos->x . " " . $this->plugin->vipSpawnPos->y . " " . $this->plugin->vipSpawnPos->z); $player->sendTip(TextFormat::BOLD . TextFormat::WHITE . "Welcome to " . TextFormat::RED . "[V.I.P.+ " . TextFormat::GOLD . "Lodge]"); return; } if (round($this->plugin->vipExitSignPos->x) === round($block->x) and round($this->plugin->vipExitSignPos->y) === round($block->y) and round($this->plugin->vipExitSignPos->z) === round($block->z)) { MapPortal::teleportingToLobby($player, $this->plugin->hubLevelName, $this->plugin->hubSpawnPos); $this->plugin->log("[HG] teleporting to HG lobby " . $this->plugin->hubSpawnPos->x . " " . $this->plugin->hubSpawnPos->y . " " . $this->plugin->hubSpawnPos->z); $player->sendTip(TextFormat::BOLD . TextFormat::WHITE . "Welcome to " . TextFormat::RED . "HG " . TextFormat::GOLD . "Lobby"); return; } } }
public function addPortal(MapPortal $p) { $this->plugin->portals[$p->name] = $p; $p->save($this->plugin->getDataFolder() . MapPortal::DIR_PORTAL_DATA); $this->plugin->log("save portal " . $p->name . " | " . $p->destination); }
public static function createSamplePortal(HungerGamesPlugIn $plugin) { $portal = new MapPortal($plugin, "sample_portal"); $portal->levelName = "portal"; $portal->displayName = "map portal"; $portal->type = self::TYPE_MAP_PORTAL; $portal->portalEnterPos1 = new Position("128", "12", "123"); $portal->portalEnterPos2 = new Position("128", "12", "123"); $portal->enterpos = new Position("128", "12", "123"); $portal->enterLevelName = "HG_Island"; $portal->portalExitPos1 = new Position("128", "12", "123"); $portal->portalExitPos2 = new Position("128", "12", "123"); $portal->exitpos = new Position("128", "12", "123"); $portal->exitLevelName = "MinigamesHub"; $portal->location = new Position("128", "12", "123"); $portal->maps = array("catching_fire", "hg_tornament"); $portal->save($plugin->getDataFolder()); }
/** * * Handle Tap On Arena Signs * * @param Player $player * @param unknown $b * @return boolean */ public function handleTapOnArenaSigns(Player $player, $b) { foreach ($this->arenas as &$arena) { if ($arena instanceof MapArenaModel) { // tap on vote sign if (!empty($arena->signVote)) { $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z); $casePosKey = round($arena->signVote->x) . "." . round($arena->signVote->y) . "." . round($arena->signVote->z); if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") { if (!$arena->published) { $player->sendMessage("[HG] This map is not available yet! please try another one."); break; } $players[] = $player; $player->getLevel()->addSound(new ClickSound($player->getPosition()), $players); MagicUtil::addParticles($player->getLevel(), "reddust", $arena->signVote, 20); if ($arena->vote === 0 && isset($arena->votedPlayers[$player->getName()])) { unset($arena->votedPlayers[$player->getName()]); } if (!isset($arena->votedPlayers[$player->getName()])) { $arena->vote++; $arena->votedPlayers[$player->getName()] = $player; } else { $player->sendMessage(TextFormat::YELLOW . "[HG] Already voted! [" . $arena->displayName . "]"); } $player->sendMessage(TextFormat::GRAY . "[HG] " . $arena->displayName . " map votes [" . TextFormat::YELLOW . $arena->vote . TextFormat::GRAY . "]"); break; } } if (!empty($arena->signExit) && !empty($arena->arenaExitPos)) { $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z); $casePosKey = round($arena->signExit->x) . "." . round($arena->signExit->y) . "." . round($arena->signExit->z); if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") { $players[] = $player; $player->level->addSound(new ClickSound($player->getPosition()), $players); MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100); unset($arena->joinedPlayers[$player->getName()]); unset($arena->livePlayers[$player->getName()]); $player->teleport($arena->arenaExitPos); break; } } if (!empty($arena->signJoin) && !empty($arena->arenaEnterPos)) { $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z); $casePosKey = round($arena->signJoin->x) . "." . round($arena->signJoin->y) . "." . round($arena->signJoin->z); if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") { $players[] = $player; $player->level->addSound(new ClickSound($player->getPosition()), $players); MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100); MapPortal::teleportToMap($arena->levelName, $player); $player->teleport($arena->arenaEnterPos); break; } } } } }
public function portalExit($pos, Player $player) { if (min($this->portalExitPos1->getX(), $this->portalExitPos2->getX()) <= $pos->getX() && max($this->portalExitPos1->getX(), $this->portalExitPos2->getX()) >= $pos->getX() && min($this->portalExitPos1->getY(), $this->portalExitPos2->getY()) <= $pos->getY() && max($this->portalExitPos1->getY(), $this->portalExitPos2->getY()) >= $pos->getY() && min($this->portalExitPos1->getZ(), $this->portalExitPos2->getZ()) <= $pos->getZ() && max($this->portalExitPos1->getZ(), $this->portalExitPos2->getZ()) >= $pos->getZ()) { $player->onGround = true; MapPortal::teleportToMap($this->exitLevelName, $player); $player->teleport($this->arenaExitPos); $player->onGround = false; $this->removePlayerFromArena($player); return true; } else { return false; } }
/** * * @param GameLevelModel $lv */ public function handleLevelGameOver(GameLevelModel &$lv) { $start = microtime(true); if (!empty($lv->currentMap)) { if (count($lv->currentMap->livePlayers) === 0) { Server::getInstance()->broadcastMessage(TextFormat::AQUA . "[HG] Game ended without winner!", $lv->currentMap->joinedPlayers); } if (count($lv->currentMap->livePlayers) > 0) { foreach ($lv->currentMap->livePlayers as $gamer) { if ($gamer instanceof GamePlayer) { $lv->level->addSound(new FizzSound($gamer->player), array($gamer->player)); $lv->level->addSound(new PopSound($gamer->player), array($gamer->player)); if (count($lv->currentMap->livePlayers) === 1) { if (isset($lv->currentMap->playerscores[$gamer->player->getName()])) { $scores = $lv->currentMap->playerscores[$gamer->player->getName()]; if ($scores != null) { $message = TextFormat::WHITE . "Final : "; $message .= TextFormat::AQUA . "shots " . TextFormat::LIGHT_PURPLE . $scores["shots"] . TextFormat::GRAY . " | "; $message .= TextFormat::AQUA . "points " . TextFormat::LIGHT_PURPLE . $scores["hits"] . TextFormat::GRAY . " | "; $message .= "\n"; $winmsg = TextFormat::GOLD . "--------------------------------------\n"; $winmsg .= TextFormat::GOLD . TextFormat::WHITE . " " . TextFormat::BOLD . TextFormat::LIGHT_PURPLE . "BRAVO " . TextFormat::WHITE . "[" . TextFormat::GOLD . $gamer->player->getName() . TextFormat::WHITE . "] Won [" . TextFormat::GOLD . $lv->winnerCoins . TextFormat::WHITE . "] coins \n"; $winmsg .= TextFormat::WHITE . " Level: " . TextFormat::GREEN . $lv->displayName . TextFormat::WHITE . " | Map: " . TextFormat::GREEN . $lv->currentMap->name . "\n"; $winmsg .= TextFormat::GREEN . " " . $message . "\n"; $winmsg .= TextFormat::GOLD . "--------------------------------------\n"; Server::getInstance()->broadcastMessage($winmsg, $lv->currentMap->joinedPlayers); if (isset($lv->currentMap->playerscores[$gamer->player->getName()])) { unset($lv->currentMap->playerscores[$gamer->player->getName()]); } if (isset($lv->currentMap->votedPlayers[$gamer->player->getName()])) { unset($lv->currentMap->votedPlayers[$gamer->player->getName()]); } $pmap = $lv->currentMap->name; $recordwins = new HungerGamesRecordWinsTask($this->plugin, $lv, $pmap, $gamer->player->getName(), $scores["hits"]); $this->plugin->getServer()->getScheduler()->scheduleDelayedTask($recordwins, mt_rand(2, 5)); for ($i = 0; $i < 50; $i++) { $gamer->player->sendTip(TextFormat::BOLD . TextFormat::GOLD . "[ = V I C T O R Y ! = ]"); } } } } else { if (isset($lv->currentMap->playerscores[$gamer->player->getName()])) { $scores = $lv->currentMap->playerscores[$gamer->player->getName()]; if ($scores != null) { $message = TextFormat::WHITE . "Final : "; $message .= TextFormat::AQUA . "shots " . TextFormat::LIGHT_PURPLE . $scores["shots"] . TextFormat::GRAY . " | "; $message .= TextFormat::AQUA . "points " . TextFormat::LIGHT_PURPLE . $scores["hits"] . TextFormat::GRAY . " | "; $message .= "\n"; } } for ($i = 0; $i < 50; $i++) { $gamer->player->sendTip(TextFormat::BOLD . TextFormat::AQUA . "[ * IT'S A DRAW ! * ]"); } $drawmsg = TextFormat::RED . "--------------------------------------\n"; $drawmsg .= TextFormat::RED . " -more than 1 player remains [" . count($lv->currentMap->livePlayers) . "]\n"; $drawmsg .= TextFormat::WHITE . " " . TextFormat::BOLD . TextFormat::YELLOW . "IT's A DRAW " . TextFormat::WHITE . "[" . TextFormat::GOLD . $gamer->player->getName() . TextFormat::WHITE . "]" . TextFormat::WHITE . "- try again?\n"; $drawmsg .= TextFormat::GREEN . " " . $message . "\n"; $drawmsg .= TextFormat::RED . "--------------------------------------" . "\n"; Server::getInstance()->broadcastMessage($drawmsg, $lv->currentMap->joinedPlayers); } $lv->level->addSound(new FizzSound($gamer->player), array($gamer->player)); MapPortal::teleportToMap($lv->levelName, $gamer->player); for ($i = 0; $i < 500; $i++) { } MapPortal::safeTeleporting($gamer->player, $lv->currentMap->arenaExitPos); foreach ($lv->currentMap->livePlayers as $gp) { $gamer->showPlayerTo($gp->player); } if (!empty($gamer->player->getInventory())) { HungerGameKit::clearAllInventories($gamer->player); $gamer->player->getInventory()->clearAll(); $gamer->player->setHealth(20); } MagicUtil::addEffect($gamer->player, Effect::JUMP, 10); MagicUtil::addParticles($gamer->player->level, "heart", $gamer->player->getPosition(), 30); $players[] = $gamer->player; $lv->level->addSound(new PopSound($gamer->player), $players); } } } try { $task = new HungerGamesMapResetTask($this->plugin, $lv->currentMap); $this->plugin->getServer()->getScheduler()->scheduleDelayedTask($task, 12); foreach ($lv->maps as $mapname) { if (isset($this->plugin->getAvailableArenas()[$mapname])) { $this->plugin->log($lv->name . "> * reset votes for map: " . $mapname); $arena = $this->plugin->getAvailableArenas()[$mapname]; $arena->vote = 0; $arena->votedPlayers = []; $this->plugin->getAvailableArenas()[$mapname] = $arena; break; } } $lv->joinDownCounter = 10; } catch (Exception $e) { $this->plugin->printError($e); } } $this->plugin->log("#8 " . $lv->name . " handleLevelGameOver took " . (microtime(true) - $start) . " ms"); }
/** * onCommand * * @param CommandSender $sender * @param Command $command * @param unknown $label * @param array $args * @return boolean */ public function onCommand(CommandSender $sender, Command $command, $label, array $args) { $output = TextFormat::GRAY . $this->plugin->version . "\n"; $output .= TextFormat::GRAY . "--------------------------------------\n"; if (strtolower($command->getName()) === "hg" && isset($args[0]) || $command->getName() === "hg2") { /** * PLAYER COMMANDS */ if (strtolower($args[0]) == "help") { $this->showPlayerHelpCommands($sender); return true; } if (strtolower($args[0]) == "adminhelp") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } $this->showAdminHelpCommands($sender); return true; } if (strtolower($args[0]) == "maphelp") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } $this->showAdminMapHelpCommands($sender); return true; } if (strtolower($args[0]) == "levelhelp") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } $this->showAdminLevelSetupHelpCommands($sender); return true; } if (strtolower($args[0]) == "arenahelp") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } $this->showAdminArenaSetupHelpCommands($sender); return true; } if (strtolower($args[0]) === "parkour") { if ($sender instanceof Player) { if ($sender->getLevel()->getName() != $this->plugin->hubLevelName) { $sender->sendMessage("[HG] You are not at Lobby!"); return; } if (!empty($this->plugin->hubLobbyParkourPos)) { $sender->sendMessage(TextFormat::GRAY . "[HG] TP to Parkour..."); $sender->teleport($this->plugin->hubLobbyParkourPos); } } return; } if (strtolower($args[0]) === "players") { if ($sender instanceof Player) { $sender->sendMessage("[HG] online players " . TextFormat::AQUA . count($this->plugin->getServer()->getOnlinePlayers())); } return; } // player lobby if (strtolower($args[0]) === "exit" || strtolower($args[0]) === "lobby" || strtolower($args[0]) === "home") { $sender->sendMessage(TextFormat::GRAY . "[HG] TP to Lobby..."); if ($sender instanceof Player) { if ($sender instanceof Player) { MapPortal::teleportingToLobby($sender, $this->plugin->hubLevelName, $this->plugin->hubSpawnPos); $this->plugin->gameLevelManager->handlePlayerLeaveTheGame($sender); } } return; } // player VIP+ lobby if (strtolower($args[0]) === "vip" || strtolower($args[0]) === "viplodge" || strtolower($args[0]) === "lodge") { if ($sender instanceof Player) { if ($sender instanceof Player) { if ($this->plugin->vipenforceaccess) { $vip = $this->plugin->profileManager->isPlayerVIP($sender->getName()); if (!$vip) { $sender->sendMessage(TextFormat::YELLOW . "[HG] Required" . TextFormat::RED . " VIP+ " . TextFormat::YELLOW . "membership!"); return; } $sender->sendMessage(TextFormat::GRAY . "[HG] TP to VIP+ lodge..."); MapPortal::teleportingToLobby($sender, $this->plugin->vipLevelName, $this->plugin->vipSpawnPos); $this->plugin->gameLevelManager->handlePlayerLeaveTheGame($sender); } else { $sender->sendMessage(TextFormat::GRAY . "[HG] TP to VIP+ lodge..."); MapPortal::teleportingToLobby($sender, $this->plugin->vipLevelName, $this->plugin->vipSpawnPos); $this->plugin->gameLevelManager->handlePlayerLeaveTheGame($sender); } } } return; } if (strtolower($args[0]) === "mybalance") { $data = $this->plugin->profileManager->retrievePlayerBalance($sender->getName()); if ($data == null || count($data) === 0) { $sender->sendMessage(TextFormat::GRAY . "[HG] No profile found"); } else { $sender->sendMessage(TextFormat::WHITE . "[HG] My balance is " . TextFormat::GOLD . $data[0]["balance"] . TextFormat::WHITE . " coins."); } return; } if (strtolower($args[0]) === "toprank") { $topWinners = $this->plugin->profileManager->retrieveTopPlayers(); if (is_null($topWinners)) { $sender->sendMessage(TextFormat::GRAY . "[HG] No record found!"); return; } $message = TextFormat::BOLD . TextFormat::DARK_RED . "HALL OF FAME\n"; $message = TextFormat::BOLD . TextFormat::AQUA . "BEST OF THE BEST\n"; if (count($topWinners) == 1) { $goldPlayerName = $topWinners[0]["pname"]; $goldPlayerWins = $topWinners[0]["wins"]; $message .= TextFormat::GOLD . "Top #1 "; $message .= TextFormat::GOLD . " " . $goldPlayerWins . TextFormat::WHITE . " Wins " . TextFormat::LIGHT_PURPLE . $goldPlayerName; $sender->sendMessage($message); } elseif (count($topWinners) == 2) { $goldPlayerName = $topWinners[0]["pname"]; $goldPlayerWins = $topWinners[0]["wins"]; $silverPlayerName = $topWinners[1]["pname"]; $silverPlayerWins = $topWinners[1]["wins"]; $message .= TextFormat::GOLD . "Top #1 "; $message .= TextFormat::GOLD . " " . $goldPlayerWins . TextFormat::WHITE . " Wins " . TextFormat::LIGHT_PURPLE . $goldPlayerName; $message .= TextFormat::GOLD . "\nTop #2 "; $message .= TextFormat::GOLD . " " . $silverPlayerWins . TextFormat::WHITE . " Wins " . TextFormat::LIGHT_PURPLE . $silverPlayerName; $sender->sendMessage($message); } elseif (count($topWinners) == 3) { $goldPlayerName = $topWinners[0]["pname"]; $goldPlayerWins = $topWinners[0]["wins"]; $silverPlayerName = $topWinners[1]["pname"]; $silverPlayerWins = $topWinners[1]["wins"]; $brownsePlayerName = $topWinners[2]["pname"]; $brownsePlayerNameWins = $topWinners[2]["wins"]; $message .= TextFormat::GOLD . "Top #1 "; $message .= TextFormat::GOLD . " " . $goldPlayerWins . TextFormat::WHITE . " Wins " . TextFormat::LIGHT_PURPLE . $goldPlayerName; $message .= TextFormat::GOLD . "\nTop #2 "; $message .= TextFormat::GOLD . " " . $silverPlayerWins . TextFormat::WHITE . " Wins " . TextFormat::LIGHT_PURPLE . $silverPlayerName; $message .= TextFormat::GOLD . "\nTop #3 "; $message .= TextFormat::GOLD . " " . $brownsePlayerNameWins . TextFormat::WHITE . " Wins " . TextFormat::LIGHT_PURPLE . $brownsePlayerName; $sender->sendMessage($message); } $data = $this->plugin->profileManager->retrievePlayerStats($sender->getName()); if (count($data) > 0) { $output = TextFormat::GREEN . "\nMy Wins: " . $data[0]["wins"]; $sender->sendMessage($output); } return; } if (strtolower($args[0]) === "myprofile") { $data = $this->plugin->profileManager->retrievePlayerByName($sender->getName()); if ($data == null || count($data) == 0) { $output = "[HG] No profile found"; } else { $output = ""; $output .= TextFormat::BOLD . "[HG] Profile Information> \n"; $output .= " balance: " . $data[0]["balance"] . "\n"; $output .= " wins: " . $data[0]["wins"] . "\n"; $output .= " loss: " . $data[0]["loss"] . "\n"; } $sender->sendMessage(TextFormat::GRAY . $output); return; } if (strtolower($args[0]) === "mywins") { // $data = $this->plugin->storyManager->retrievePlayerWinsByLevelMap ( $sender->getName () ); // if ($data == null || count ( $data ) == 0) { // $output = "[HG] No level record found"; // } else { // $output= TextFormat::BOLD.TextFormat::AQUA."MY WINS BY LEVEL\n"; // $output .= TextFormat::GRAY ."| level | wins | loss | points | map |\n"; // foreach ( $data as $record ) { // $output.="| "; // $output .= TextFormat::GREEN .$record ["level"] . TextFormat::GRAY . " | "; // $output .= TextFormat::GOLD .$record ["wins"] . TextFormat::GRAY . " | "; // $output .= TextFormat::WHITE .$record ["loss"] . TextFormat::GRAY . " | "; // $output .= TextFormat::BLUE . $record ["points"] .TextFormat::GRAY." | "; // $output .= TextFormat::ITALIC.TextFormat::WHITE .$record ["map"] . TextFormat::GRAY . " \n"; // } // $output .= TextFormat::GRAY . "\n"; // } // $sender->sendMessage ( TextFormat::GRAY . $output ); $this->showMyWins($sender, $args); return; } if (strtolower($args[0]) === "mypoints") { $data = $this->plugin->storyManager->retrievePlayerWinsByPoints($sender->getName()); if ($data == null || count($data) == 0) { $output = "[HG] No level record found"; } else { $output = TextFormat::BOLD . TextFormat::AQUA . "MY POINTS BY MAP\n"; $output .= TextFormat::GRAY . "| level | wins | loss | points | map |\n"; foreach ($data as $record) { $output .= "| "; $output .= TextFormat::WHITE . $record["level"] . TextFormat::GRAY . " | "; $output .= TextFormat::BLUE . $record["wins"] . TextFormat::GRAY . " | "; $output .= TextFormat::WHITE . $record["loss"] . TextFormat::GRAY . " | "; $output .= TextFormat::GOLD . $record["points"] . TextFormat::GRAY . " | "; $output .= TextFormat::UNDERLINE . TextFormat::GREEN . $record["map"] . TextFormat::GRAY . " \n"; } $output .= TextFormat::GRAY . "\n"; } $sender->sendMessage(TextFormat::GRAY . $output); return; } if (strtolower($args[0]) === "topwins") { if (count($args) != 2) { $message = "[HG]-Usage: /hg topwins [level|map]"; $sender->sendMessage($message); return; } if ($args[1] != "level" && $args[1] != "map") { $message = "[HG] Usage: /hg topwins [level|map]"; $sender->sendMessage($message); return; } $data = []; $output = ""; if ($args[1] === "level") { $output = TextFormat::BOLD . TextFormat::BLUE . "TOP WINS BY [LEVEL]\n"; $data = $this->plugin->storyManager->retrieveTopLevelPlayers(); } if ($args[1] === "map") { $output = TextFormat::BOLD . TextFormat::BLUE . "TOP WINS BY [MAP]\n"; $data = $this->plugin->storyManager->retrieveTopMapPlayers(); } if ($data === null || count($data) === 0) { $output = "[HG] No records found"; } else { if ($args[1] === "map") { $output .= TextFormat::GRAY . "| level | wins | loss | points | map | player |\n"; } else { $output .= TextFormat::GRAY . "| level | wins | loss | points | player |\n"; } foreach ($data as $record) { $output .= "| "; if ($args[1] === "map") { $output .= TextFormat::WHITE . $record["level"] . TextFormat::GRAY . " | "; } else { $output .= TextFormat::GREEN . $record["level"] . TextFormat::GRAY . " | "; } $output .= TextFormat::GOLD . $record["wins"] . TextFormat::GRAY . " | "; $output .= TextFormat::WHITE . $record["loss"] . TextFormat::GRAY . " | "; $output .= TextFormat::WHITE . $record["points"] . " | "; if ($args[1] === "map") { $output .= TextFormat::GREEN . $record["map"] . TextFormat::GRAY . " | "; } $output .= TextFormat::AQUA . $record["pname"] . TextFormat::GRAY . " \n"; } $output .= TextFormat::GRAY . "\n"; } $sender->sendMessage(TextFormat::GRAY . $output); return; } /* * MAP ADMINISTRATION */ // player admin panel if (strtolower($args[0]) === "adminpanel" || strtolower($args[0]) === "admin") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } $sender->sendMessage(TextFormat::GRAY . "[HG] TP to admin panel..."); if ($sender instanceof Player) { MapPortal::teleportingToLobby($sender, $this->plugin->hubAdminPanelLevelName, $this->plugin->hubAdminPanelPos); $this->plugin->gameLevelManager->handlePlayerLeaveTheGame($sender); } return; } // player admin panel if (strtolower($args[0]) === "vipadminpanel" || strtolower($args[0]) === "vipadmin") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } $sender->sendMessage(TextFormat::GRAY . "[HG] TP to VIP admin panel..."); if ($sender instanceof Player) { MapPortal::teleportingToLobby($sender, $this->plugin->hubAdminVIPPanelLevelName, $this->plugin->hubAdminVIPPanelPos); $this->plugin->gameLevelManager->handlePlayerLeaveTheGame($sender); } return; } // teleport to arenas if (strtolower($args[0]) === "tpa") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } $sender->sendMessage(TextFormat::GRAY . "[HG] TP to arena..."); if ($sender instanceof Player) { if (count($args) != 2) { $sender->sendMessage("usage: /hg tpa [arena name]"); return; } if (!isset($this->plugin->arenaManager->arenas[$args[1]])) { $sender->sendMessage("[HG] Arena name not found: " . $args[1]); return; } $arena = $this->plugin->arenaManager->arenas[$args[1]]; if (empty($arena)) { $sender->sendMessage("[HG] Arena not found: " . $args[1]); return; } if ($arena instanceof MapArenaModel) { if (empty($arena->enterLevelName) || empty($arena->arenaEnterPos)) { $sender->sendMessage("[HG] Missing Arena level configuration: " . $args[1]); return; } $sender->sendMessage(TextFormat::GRAY . "[HG] TP to VIP+ lodge..."); MapPortal::teleportingToLobby($sender, $arena->enterLevelName, $arena->arenaEnterPos); } } return; } /* * PLAYER PROFILE ADMINISTRATION */ if (strtolower($args[0]) === "setbalance") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } if (count($args) != 3) { $sender->sendMessage("usage: /hg setbalance [player name] [amount]"); return; } // check if player exit in the server $playerName = $args[1]; $olp = Server::getInstance()->getPlayerExact($playerName); if (empty($olp)) { $offp = Server::getInstance()->getOfflinePlayer($playerName); if (empty($offp)) { $sender->sendMessage(TextFormat::YELLOW . "[HG] Player Not Found! "); return; } } $rs = $this->plugin->profileManager->setBalance($args[1], $args[2]); $sender->sendMessage(TextFormat::GREEN . "[HG] player [" . $playerName . "] balance updated | " . $rs); return; } if (strtolower($args[0]) === "addvip") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } if (count($args) != 2) { $sender->sendMessage(TextFormat::GREEN . "usage: /hg addvip [player name]"); return; } $playerName = $args[1]; $rs = $this->plugin->profileManager->upsetVIP($playerName, "true"); $sender->sendMessage(TextFormat::GREEN . "[HG] VIP [" . TextFormat::GOLD . $playerName . TextFormat::GREEN . "] Added (" . $rs . ")!"); return; } if (strtolower($args[0]) === "getvip") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } if (count($args) != 2) { $sender->sendMessage(TextFormat::GREEN . "usage: /hg getvip [player name]"); return; } $playerName = $args[1]; $data = $this->plugin->profileManager->retrievePlayerVIP($playerName); if (empty($data) || count($data) === 0) { $sender->sendMessage(TextFormat::YELLOW . "[HG] VIP profile Not Found!"); return; } $output = ""; $output .= TextFormat::BOLD . "[HG] VIP Player Profile: \n"; $output .= TextFormat::DARK_GREEN . "- player: " . TextFormat::AQUA . $data[0]["pname"] . "\n"; $output .= TextFormat::DARK_GREEN . "- vip: " . TextFormat::GOLD . $data[0]["vip"] . "\n"; $output .= TextFormat::DARK_GREEN . "- balance: " . TextFormat::WHITE . $data[0]["balance"] . "\n"; $output .= TextFormat::DARK_GREEN . "- wins: " . TextFormat::WHITE . $data[0]["wins"] . "\n"; $output .= TextFormat::DARK_GREEN . "- loss: " . TextFormat::WHITE . $data[0]["loss"] . "\n"; $output .= TextFormat::DARK_GREEN . "- ludt: " . TextFormat::WHITE . $data[0]["lupt"] . "\n"; $sender->sendMessage($output); return; } if (strtolower($args[0]) === "delvip") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } if (count($args) != 2) { $sender->sendMessage("usage: /hg delvip [player name]"); return; } // check if player exit in the server $playerName = $args[1]; $olp = Server::getInstance()->getPlayerExact($playerName); if (empty($olp)) { $offp = Server::getInstance()->getOfflinePlayer($playerName); if (empty($offp)) { $sender->sendMessage(TextFormat::YELLOW . "[HG] Player Not Found! "); return; } } $rs = $this->plugin->profileManager->upsetVIP($playerName, "false"); $sender->sendMessage(TextFormat::GREEN . "[HG] VIP [" . TextFormat::GOLD . $playerName . TextFormat::GREEN . "] delete (" . $rs . ")!"); return; } if (strtolower($args[0]) === "createprofile") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } if (count($args) != 2) { $sender->sendMessage("usage: /hg createprofile [player name]"); return; } $rs = $this->plugin->profileManager->addPlayer($args[1]); $sender->sendMessage(TextFormat::GREEN . "[HG] player profile created! " . $rs); return; } if (strtolower($args[0]) === "changename") { if (!$sender->isOp()) { $output = TextFormat::YELLOW . "You are not authorized to run this command.\n"; $sender->sendMessage($output); return; } if (count($args) != 3) { $sender->sendMessage("usage: /hg changename [old name] [new name]"); return; } $pname = $args[1]; $newname = $args[2]; $rs1 = $this->plugin->profileManager->isPlayerExist($pname); if (empty($rs1) || count($rs1) === 0) { $sender->sendMessage(TextFormat::GREEN . "[HG] player profile record not found!"); return; } $rs2 = $this->plugin->profileManager->isPlayerExist($pname); if (empty($rs2) || count($rs2) === 0) { $sender->sendMessage(TextFormat::GREEN . "[HG] player story record not found!"); return; } try { $this->plugin->profileManager->changePlayerName($pname, $newname); $this->plugin->storyManager->changePlayerName($pname, $newname); $sender->sendMessage(TextFormat::GREEN . "[HG] Success! change from [" . $pname . "] to [" . $newname . "]"); } catch (Exception $e) { $this->plugin->printError($e); $sender->sendMessage(TextFormat::GREEN . "[HG] Failed! " . $e->getMessage()); } return; } /** * ADMIN COMMANDS */ if (strtolower($args[0]) === "setgamelobby") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetGameLobbyCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setserverlobby") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetServerLobbyCommand($sender->getPlayer(), $args); return; } /** * SETUP ARENA COMMANDS */ if (strtolower($args[0]) === "newarena") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] In-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->createArena($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "arenawand") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleArenaWandCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setarenapos1") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaPosition1Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setarenapos2") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaPosition2Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setarenawall") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaWallCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setarenaspawn") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaPlayerSpawnCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "startspawnwand") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleArenaWandPlayerSpawnPointCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "stopspawnwand") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $session =& $this->plugin->arenaManager->session($sender); if ($session != null && $session["wand-usage"] === true) { $session["wand-usage"] = false; if (!isset($session["spawn-pos"])) { unset($session["spawn-pos"]); } } $output = TextFormat::GREEN . "[HG] Player Spawn Wand Stopped!"; $sender->sendMessage($output); return; } if (strtolower($args[0]) === "listspawns") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->ListArenaPlayerSpawnCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "clearspawns") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->clearArenaPlayerSpawnPointsCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setarenaenter") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaEntranceCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setarenaexit") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaExitCommand($sender->getPlayer(), $args); return; } /** * SETUP DEATH-MATCH ARENA COMMANDS */ if (strtolower($args[0]) === "matchwand") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleArenaDeathMatchWandCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setmatchpos1") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaDeathMatchPosition1Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setmatchpos2") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaDeathMatchPosition2Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setmatchenter") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetArenaDeathMatchEntranceCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setmatchwall") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetDeathMatchWallsCommand($sender->getPlayer(), $args); return; } /** * Arena Publishing */ if (strtolower($args[0]) === "publish") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleActivateArenaCommand($sender->getPlayer(), $args); $this->plugin->arenaManager->preloadArenas(); return; } if (strtolower($args[0]) === "unpublish") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleDeActivateArenaCommand($sender->getPlayer(), $args); $this->plugin->arenaManager->preloadArenas(); return; } /** * Level Management */ if (strtolower($args[0]) === "addlevelarena") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->gameLevelManager->handleAdditionOfLevelArenaCommand($sender->getPlayer(), $args); $this->plugin->gameLevelManager->preloadArenas(); return; } if (strtolower($args[0]) === "dellevelarena") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->gameLevelManager->handleRemovalOfLevelArenaCommand($sender->getPlayer(), $args); $this->plugin->gameLevelManager->preloadArenas(); return; } /** * SETUP GAME LEVEL */ if (strtolower($args[0]) === "levelwand") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->gameLevelManager->handleLevelWandCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setlevelpos1") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetGamePortalPosition1Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setlevelpos2") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetGamePortalPosition2Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "levelgatewand") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->gameLevelManager->handleLevelGateWandCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setlevelgatepos1") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetGamePortalGate1Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setlevelgatepos2") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->arenaManager->handleSetGamePortalGate2Command($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setlevelenter") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->gameLevelManager->handleSetLevelEntranceCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "setlevelexit") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if (!$sender instanceof Player) { $output .= "[HG] in-game command only!"; $sender->sendMessage($output); return; } $this->plugin->gameLevelManager->handleSetLevelExitCommand($sender->getPlayer(), $args); return; } if (strtolower($args[0]) === "blockon") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } $this->plugin->blockhud = true; $sender->sendMessage("[HG] Admin Block Location Display " . TextFormat::GREEN . "[ON]"); return; } if (strtolower($args[0]) === "blockoff") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } $this->plugin->blockhud = false; $sender->sendMessage("[HG] Admin Block Location Display " . TextFormat::RED . "[OFF]"); return; } if (strtolower($args[0]) === "xyz") { if (!$sender->isOp()) { $sender->sendMessage("[HG] No authorization!"); return; } if ($sender instanceof Player) { $portalLevel = $sender->level->getName(); $sender->sendMessage("You are in world [" . $portalLevel . "] at \n[ " . round($sender->x) . " " . round($sender->y) . " " . round($sender->z) . " ]"); } return; } } }