Esempio n. 1
0
 /**
  * Really starts the duel after countdown
  */
 public function startDuel()
 {
     Server::getInstance()->getScheduler()->cancelTask($this->countdownTaskHandler->getTaskId());
     $player1 = $this->players[0];
     $player2 = $this->players[1];
     $pos_player1 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player1->x += self::PLAYER_1_OFFSET_X;
     $pos_player2 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player2->x += self::PLAYER_2_OFFSET_X;
     $player1->teleport($pos_player1, 90, 0);
     $player2->teleport($pos_player2, -90, 0);
     // Give kit
     foreach ($this->players as $player) {
         $this->giveKit($player);
     }
     // Fix start time
     $this->startTime = new DateTime('now');
     $player1->sendTip(OneVsOne::getMessage("duel_tip"));
     $player1->sendMessage(OneVsOne::getMessage("duel_start"));
     $player2->sendTip(OneVsOne::getMessage("duel_tip"));
     $player2->sendMessage(OneVsOne::getMessage("duel_start"));
     // Launch the end round task
     $task = new RoundCheckTask(OneVsOne::getInstance());
     $task->arena = $this;
     $this->taskHandler = Server::getInstance()->getScheduler()->scheduleDelayedTask($task, self::ROUND_DURATION * 20);
 }
 /**
  * Init the arenas
  */
 public function init(Config $config)
 {
     PluginUtils::logOnConsole(TextFormat::GREEN . "Init" . TextFormat::RED . " ArenaManager");
     $this->config = $config;
     if (!$this->config->arenas) {
         $this->config->set('arenas', []);
         $arenaPositions = [];
     } else {
         $arenaPositions = $this->config->arenas;
     }
     if (!$this->config->signs) {
         $this->config->set('signs', []);
         $signPositions = [];
     } else {
         $signPositions = $this->config->signs;
     }
     // Load arenas and signs
     $this->parseArenaPositions($arenaPositions);
     $this->parseSignPositions($signPositions);
     // Launch sign refreshing task
     $task = new SignRefreshTask(OneVsOne::getInstance());
     $task->arenaManager = $this;
     $this->signRefreshTaskHandler = $this->getServer()->getScheduler()->scheduleRepeatingTask($task, self::SIGN_REFRESH_DELAY * 20);
     //Using a Static Function(Server::getInstance is bad practise! Fixed this.
 }
 /**
  * Init the arenas
  */
 public function init(Config $config)
 {
     PluginUtils::logOnConsole("- Init ArenaManager");
     $this->config = $config;
     if (!$this->config->arenas) {
         $this->config->set('arenas', []);
         $arenaPositions = [];
     } else {
         $arenaPositions = $this->config->arenas;
     }
     if (!$this->config->signs) {
         $this->config->set('signs', []);
         $signPositions = [];
     } else {
         $signPositions = $this->config->signs;
     }
     // Load arenas and signs
     $this->parseArenaPositions($arenaPositions);
     $this->parseSignPositions($signPositions);
     // Launch sign refreshing task
     $task = new SignRefreshTask(OneVsOne::getInstance());
     $task->arenaManager = $this;
     $this->signRefreshTaskHandler = Server::getInstance()->getScheduler()->scheduleRepeatingTask($task, self::SIGN_REFRESH_DELAY * 20);
 }
 /**
  * Really starts the duel after countdown
  */
 public function startDuel()
 {
     Server::getInstance()->getScheduler()->cancelTask($this->countdownTaskHandler->getTaskId());
     $player1 = $this->players[0];
     $player2 = $this->players[1];
     $pos_player1 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player1->x += self::PLAYER_1_OFFSET_X;
     $pos_player2 = Position::fromObject($this->position, $this->position->getLevel());
     $pos_player2->x += self::PLAYER_2_OFFSET_X;
     $player1->teleport($pos_player1, 90, 0);
     $player2->teleport($pos_player2, -90, 0);
     // Fix start time
     $this->startTime = new DateTime('now');
     $player1->sendTip(TextFormat::RED . "You are strarting a duel !");
     $player1->sendMessage(" ");
     $player1->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player1->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You're starting a duel against : " . $player2->getName() . " !");
     $player1->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You have 3min !");
     $player1->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " Good luck :) !");
     $player1->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player1->sendMessage(" ");
     $player1->sendTip(TextFormat::RED . "You are strarting a duel !");
     $player2->sendMessage(" ");
     $player2->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player2->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You're starting a duel against : " . $player1->getName() . " !");
     $player2->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " You have 3min !");
     $player2->sendMessage(TextFormat::AQUA . ">" . TextFormat::RESET . " Good luck :) !");
     $player2->sendMessage(TextFormat::RED . TextFormat::BOLD . "++++++++=++++++++");
     $player2->sendMessage(" ");
     // Launch the end round task
     $task = new RoundCheckTask(OneVsOne::getInstance());
     $task->arena = $this;
     $this->taskHandler = Server::getInstance()->getScheduler()->scheduleDelayedTask($task, self::ROUND_DURATION * 20);
 }