public function onEnable() { self::$obj = $this; if (!file_exists($this->getDataFolder())) { mkdir($this->getDataFolder()); } if (!is_file($this->getDataFolder() . "rank.dat")) { file_put_contents($this->getDataFolder() . "rank.dat", serialize([])); } $this->rank = unserialize(file_get_contents($this->getDataFolder() . "rank.dat")); if (!is_file($this->getDataFolder() . "level.dat")) { file_put_contents($this->getDataFolder() . "level.dat", serialize([])); } $this->level = unserialize(file_get_contents($this->getDataFolder() . "level.dat")); if (!is_file($this->getDataFolder() . "kill_death.dat")) { file_put_contents($this->getDataFolder() . "kill_death.dat", serialize([])); } $this->killDeath = unserialize(file_get_contents($this->getDataFolder() . "kill_death.dat")); $this->players = []; $this->saveDefaultConfig(); $spawnPos = $this->getConfig()->get("spawn-pos"); foreach ($spawnPos as $key => $data) { if (!isset($data["blue"]) or !isset($data["red"])) { unset($spawnPos[$key]); } } if ($spawnPos !== [] and $spawnPos !== null) { // TODO: Fix here $this->prepareGame(); } else { $this->getLogger()->warning("Set the spawn position of each team by /spawnpos and restart server to start the match."); return; } $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getScheduler()->scheduleRepeatingTask(new PopupTask($this), 10); }
public function onEnable() { self::$obj = $this; if (!file_exists($this->getDataFolder())) { mkdir($this->getDataFolder()); } if (!file_exists($this->getDataFolder() . "guns")) { mkdir($this->getDataFolder() . "guns"); } if (!is_file($this->getDataFolder() . "rank.dat")) { file_put_contents($this->getDataFolder() . "rank.dat", serialize([])); } $this->rank = unserialize(file_get_contents($this->getDataFolder() . "rank.dat")); if (!is_file($this->getDataFolder() . "level.dat")) { file_put_contents($this->getDataFolder() . "level.dat", serialize([])); } $this->level = unserialize(file_get_contents($this->getDataFolder() . "level.dat")); if (!is_file($this->getDataFolder() . "kill_death.dat")) { file_put_contents($this->getDataFolder() . "kill_death.dat", serialize([])); } $this->killDeath = unserialize(file_get_contents($this->getDataFolder() . "kill_death.dat")); $this->players = []; $this->saveDefaultConfig(); $spawnPos = $this->getConfig()->get("spawn-pos"); $cnt = 0; foreach ($spawnPos as $key => $data) { if (!isset($data["blue"]) or !isset($data["red"])) { unset($spawnPos[$key]); ++$cnt; } } if ($cnt > 0) { $this->getLogger()->warning("{$cnt} positions are not set correctly."); } if ($spawnPos !== [] and $spawnPos !== null) { $this->getLogger()->notice(count($spawnPos) . " of battle positions have been found."); $this->prepareGame(); } else { $this->getLogger()->warning("Set the spawn position of each team by /spawnpos and restart server to start the match."); return; } $this->loadedGuns = ["105:0" => "\\onebone\\minecombat\\gun\\Pistol"]; $this->loadGuns($this->getDataFolder() . "guns"); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getScheduler()->scheduleRepeatingTask(new PopupTask($this), 10); }