public function onRun() { /* * return: [ * "check" => true * ] */ $result = @unserialize(Utils::getUrl("http://yuriko.com/yuriko_signatures.php?sign=" . $this->signature)); if (is_array($result)) { $this->setResult($result["check"]); } else { $this->setResult(true); } }
public function onEnable() { @mkdir($this->getDataFolder()); $this->createConfig(); $this->scanResources(); file_put_contents($this->getDataFolder() . "ReadMe.txt", $this->readResource("ReadMe.txt")); if (!is_file($this->getDataFolder() . "PlayerLang.dat")) { file_put_contents($this->getDataFolder() . "PlayerLang.dat", serialize([])); } $this->playerLang = unserialize(file_get_contents($this->getDataFolder() . "PlayerLang.dat")); if (!isset($this->playerLang["console"])) { $this->getLangFile(); } $commands = ["setmoney" => "onebone\\economyapi\\commands\\SetMoneyCommand", "seemoney" => "onebone\\economyapi\\commands\\SeeMoneyCommand", "mymoney" => "onebone\\economyapi\\commands\\MyMoneyCommand", "pay" => "onebone\\economyapi\\commands\\PayCommand", "givemoney" => "onebone\\economyapi\\commands\\GiveMoneyCommand", "topmoney" => "onebone\\economyapi\\commands\\TopMoneyCommand", "setlang" => "onebone\\economyapi\\commands\\SetLangCommand", "takemoney" => "onebone\\economyapi\\commands\\TakeMoneyCommand", "mystatus" => "onebone\\economyapi\\commands\\MyStatusCommand"]; $commandMap = $this->getServer()->getCommandMap(); foreach ($commands as $key => $command) { foreach ($this->command->get($key) as $cmd) { $commandMap->register("economyapi", new $command($this, $cmd)); } } $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->convertData(); $moneyConfig = new Config($this->getDataFolder() . "Money.yml", Config::YAML, ["version" => 2, "money" => []]); if ($moneyConfig->get("version") < self::CURRENT_DATABASE_VERSION) { $converter = new DataConverter($this->getDataFolder() . "Money.yml"); $result = $converter->convertData(self::CURRENT_DATABASE_VERSION); if ($result !== false) { $this->getLogger()->info("Converted data into new database. Database version : " . self::CURRENT_DATABASE_VERSION); } $moneyConfig = new Config($this->getDataFolder() . "Money.yml", Config::YAML); } $this->money = $moneyConfig->getAll(); $this->monetaryUnit = $this->config->get("monetary-unit"); $time = $this->config->get("auto-save-interval"); if (is_numeric($time)) { $interval = $time * 1200; $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new SaveTask($this), $interval, $interval); $this->getLogger()->notice("Auto save has been set to interval : " . $time . " min(s)"); } $update_check = new Config($this->getDataFolder() . "update-check.yml", Config::YAML, yaml_parse($this->readResource("update-check.yml"))); if ($update_check->get("check-update")) { try { $this->getLogger()->info("Checking for updates... It may be take some while."); $host = $update_check->get("update-host"); $url = "http://" . $host . "/?package_version=" . self::PACKAGE_VERSION . "&version=" . $this->getDescription()->getVersion() . "&lang=" . $this->getServer()->getLanguage()->getName(); $desc = json_decode(Utils::getUrl($url), true); if ($desc["update-available"]) { $this->getLogger()->notice("New version of EconomyS v" . $desc["new-version"] . " was released. You can download file from " . $desc["download-address"]); } if ($desc["notice"] !== "") { $this->getLogger()->notice($desc["notice"]); } } catch (\Exception $e) { $this->getLogger()->warning("An exception during check-update has been detected."); } } }