public function halfSecondTick() { parent::halfSecondTick(); $count = 0; foreach ($this->matches as $match) { if ($match->getState() === MatchState::OPEN) { $count++; } } if ($count < $this->getMinOpenGames()) { $this->getHub()->getDataProvider()->fetchNextId($this); } foreach ($this->matches as $match) { $match->halfSecondTick(); } }
public function removeEntry(Game $game, string $identifier) { unset($this->entries[$name = $game->getName()->get()][$identifier]); unset($this->ordered[$name . ":" . $id]); }
public function onLoaded(DynamicHub $hub) { parent::onLoaded($hub); $this->getOwner()->getServer()->getScheduler()->scheduleRepeatingTask(new CallbackPluginTask($this->getOwner(), [$this, "halfSecondTick"]), 10); }
/** * Load a {@link Game} into the plugin * * @param Game $game * * @throws \RuntimeException */ public function loadGame(Game $game) { $owner = $game->getOwner(); if (!in_array($this->getDescription()->getName(), $owner->getDescription()->getDepend())) { throw new \RuntimeException("A Game must be owned by a plugin that depends on DynamicHub"); } if ($this->single and count($this->loadedGames) > 0) { throw new \RuntimeException("Only one Game can be loaded on this server limited in config"); } $this->loadedGames[strtolower($game->getName()->get())] = $game; $game->onLoaded($this); $this->getLogger()->info("Loaded " . $game->getName()); }