private function get_download_link($version) { $version = strtoupper($version); if (\launcher\ends_with($version, "-SNAPSHOT")) { // Dev version $meta = simplexml_load_file(self::REPO_URL . $version . "/maven-metadata.xml"); $versions = $meta->versioning->snapshotVersions->snapshotVersion; foreach ($versions as $artifact) { if ($this->type == "jar" && $artifact->extension == "jar" && !isset($artifact->classifier)) { return self::REPO_URL . "{$version}/bs-maths-" . $artifact->value . "." . $artifact->extension; } elseif ($this->type == "assets" && $artifact->classifier == "assets-index") { return self::REPO_URL . "{$version}/bs-maths-" . $artifact->value . "-" . $artifact->classifier . "." . $artifact->extension; } elseif ($this->type == "libraries" && $artifact->classifier == "libraries") { return self::REPO_URL . "{$version}/bs-maths-" . $artifact->value . "-" . $artifact->classifier . "." . $artifact->extension; } } } else { switch ($this->type) { case "jar": return self::REPO_URL . "{$version}/bs-maths-{$version}.jar"; case "assets": return self::REPO_URL . "{$version}/bs-maths-{$version}-assets-index.json"; case "libraries": return self::REPO_URL . "{$version}/bs-maths-{$version}-libraries.json"; } } return ""; }
public function handle($data) { $metadata = simplexml_load_file(self::REPO_URL . "maven-metadata.xml"); $data = []; $versions = $metadata->versioning->versions->version; foreach ($versions as $version) { $versionName = (string) $version; $data["versions"][$versionName] = ["name" => $versionName, "type" => \launcher\ends_with($versionName, "-SNAPSHOT") ? "DEVELOPMENT" : "RELEASE", "link" => self::BASE_URL . $versionName . "/", "downloads" => ["assets" => self::BASE_URL . $versionName . "/assets/", "download" => self::BASE_URL . $versionName . "/download/", "libraries" => self::BASE_URL . $versionName . "/libraries/"]]; } /* if (isset($metadata->versioning->release)) { $latest = (string)$metadata->versioning->release; $data["latest"] = [ "release" => $latest ]; }*/ $data["latest"] = ["release" => "1.0-SNAPSHOT"]; return $data; }