/** * Plugin is enabled by PocketMine server */ public function onEnable() { self::$instance = $this; PluginUtils::logOnConsole(TextFormat::GREEN . "[1vs1] - Init OneVsOne plugin"); // Get arena positions from arenas.yml @mkdir($this->getDataFolder()); $this->arenaConfig = new Config($this->getDataFolder() . "config.yml", Config::YAML, array()); $this->arenaManager = new ArenaManager(); $this->arenaManager->init($this->arenaConfig); // Register events $this->getServer()->getPluginManager()->registerEvents(new EventsManager($this->arenaManager), $this); // Register commands $joinCommand = new JoinCommand($this, $this->arenaManager); $this->getServer()->getCommandMap()->register($joinCommand->commandName, $joinCommand); $referenceArenaCommand = new ReferenceArenaCommand($this, $this->arenaManager); $this->getServer()->getCommandMap()->register($referenceArenaCommand->commandName, $referenceArenaCommand); }
public function tileupdate(SignChangeEvent $event) { if ($event->getBlock()->getID() == Item::SIGN_POST || $event->getBlock()->getID() == Block::SIGN_POST || $event->getBlock()->getID() == Block::WALL_SIGN) { $signTile = $event->getPlayer()->getLevel()->getTile($event->getBlock()); if (!$signTile instanceof Sign) { return true; } $signLines = $event->getLines(); if ($signLines[0] == OneVsOne::SIGN_TITLE) { if ($event->getPlayer()->isOp()) { $this->arenaManager->addSign($signTile); $event->setLine(1, "-Waiting: " . $this->arenaManager->getNumberOfPlayersInQueue()); $event->setLine(2, "-Arenas:" . $this->arenaManager->getNumberOfFreeArenas()); $event->setLine(3, "-+===+-"); return true; } } } }
/** * Reset the Arena to current state */ private function reset() { // Put active a rena after the duel $this->active = FALSE; foreach ($this->players as $player) { $player->getInventory()->setItemInHand(new Item(Item::AIR, 0, 0)); $player->getInventory()->clearAll(); $player->getInventory()->sendArmorContents($player); $player->getInventory()->sendContents($player); $player->getInventory()->sendHeldItem($player); } $this->players = array(); $this->startTime = NULL; if ($this->taskHandler != NULL) { Server::getInstance()->getScheduler()->cancelTask($this->taskHandler->getTaskId()); $this->manager->notifyEndOfRound($this); } }