diff --git a/src/AutoUpdater/Main.php b/src/AutoUpdater/Main.php new file mode 100644 index 0000000..3de98df --- /dev/null +++ b/src/AutoUpdater/Main.php @@ -0,0 +1,106 @@ +getDataFolder()); + $this->saveDefaultConfig(); + $this->cfg = $this->getConfig()->getAll(); + $this->getCommand("autoupdater")->setExecutor(new Commands\Commands($this)); + $this->getCommand("update")->setExecutor(new Commands\Update($this)); + $time = intval($this->cfg["update-check-time"]) * 20; + $this->getServer()->getScheduler()->scheduleRepeatingTask(new Query($this), $time * 60); + } + + public function getChannel(){ + $tmp = $this->getConfig()->getAll(); + return $tmp["channel"]; + } + + public function getStartScript(){ + $tmp = $this->getConfig()->getAll(); + return $tmp["start-script"]; + } + + public function getQuery($channel){ + $query = Utils::getURL(Main::API_URL . "?channel=" . strtolower($channel)); + $query = json_decode($query, true); + return $query; + } + + public function getFileName(){ + $tmp = $this->getConfig()->getAll(); + if(strtolower(substr($tmp["file-name"], -5)) == ".phar"){ + return $tmp["file-name"]; + }else{ + return $tmp["file-name"] . ".phar"; + } + } + + public function getTimeout(){ + $tmp = $this->getConfig()->getAll(); + return $tmp["timeout"]; + } +} +?>