From a72199cd7a8ed68a289ce2fe7fd44f1b6ac42674 Mon Sep 17 00:00:00 2001 From: Flavius12 Date: Sat, 27 Dec 2014 16:16:36 +0100 Subject: [PATCH] Create Main.php --- src/AutoUpdater/Main.php | 106 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/AutoUpdater/Main.php 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"]; + } +} +?>