public function run() { $this->reds = $this->plugin->reds; $this->blues = $this->plugin->blues; if (count($this->reds) < 5 && count($this->blues) < 5) { $this->gst = Tasks::scheduleRepeatingTask(new Tasks\GameStartTask($this), 20)->getTaskId(); Tasks::cancelTask($this->gwt); } else { $this->gwt = Tasks::scheduleRepeatingTask(new Tasks\GameWaitingTask($this), 15)->getTaskId(); } }
public function onRun($tick) { $this->seconds = $this->seconds - 1; foreach ($this->plugin->reds as $r) { foreach ($this->plugin->blues as $b) { foreach ($this->plugin->yml["items"] as $i) { Server::getInstance()->getPlayer($r)->sendPopup("§eThe game will start in {$this->seconds} second(s)!"); Server::getInstance()->getPlayer($b)->sendPopup("§eThe game will start in {$this->seconds} second(s)!"); if ($this->seconds == 1) { Server::getInstance()->getPlayer($r)->teleport(new Vector3($this->plugin->yml["red_enter_x"], $this->plugin->yml["red_enter_y"], $this->plugin->yml["red_enter_z"])); Server::getInstance()->getPlayer($b)->teleport(new Vector3($this->plugin->yml["blue_enter_x"], $this->plugin->yml["blue_enter_y"], $this->plugin->yml["blue_enter_z"])); Server::getInstance()->getPlayer($r)->getInventory()->addItem(Item::get($i)); Server::getInstance()->getPlayer($b)->getInventory()->addItem(Item::get($i)); $this->plugin->gameStarted = true; $this->seconds = 15; Tasks::cancelTask($this->getTaskId()); } } } } }