From 4e3c1edfa60dc0588819ce1b3a04a5c57e73db94 Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Mon, 23 May 2022 11:53:36 +0200 Subject: [PATCH] + fetching libraries --- launcher/.gitignore | 6 ++++++ launcher/version.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 launcher/.gitignore create mode 100755 launcher/version.sh diff --git a/launcher/.gitignore b/launcher/.gitignore new file mode 100644 index 0000000..231b434 --- /dev/null +++ b/launcher/.gitignore @@ -0,0 +1,6 @@ +client_id +ms_auth_blob +xbl_auth_blob +xsts_auth_blob +auth.json +version_manifest.json diff --git a/launcher/version.sh b/launcher/version.sh new file mode 100755 index 0000000..4990a7c --- /dev/null +++ b/launcher/version.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +function fetch_manifest() { + if [[ ! -f version_manifest.json ]]; then + curl https://launchermeta.mojang.com/mc/game/version_manifest.json -O + fi +} + +function list_versions() { + fetch_manifest + + jq -r '.versions[] | "\(.id)"' < version_manifest.json +} + +function fetch_version() { + fetch_manifest + + local url=$(jq -r '.versions[] | "\(.id),\(.url)"' < version_manifest.json | grep -P "^$1," | awk -F, '{print $2}') + if [[ "$url" == '' ]]; then + echo "Bad version?" + return 1 + fi + + mkdir meow; cd meow + curl -O "$url" + + mew="$(jq -r '.libraries[].downloads | if .classifiers then select(.classifiers["natives-linux"]) | .classifiers["natives-linux"] else .artifact end | "\(.url) \(.path)"' < $(basename "$url"))" + + IFS=$'\n' + for i in $mew; do + url=$(awk '{print $1}' <<< "$i") + path=$(awk '{print $2}' <<< "$i") + mkdir -p $(dirname "$path") + curl -o "$path" "$url" + done + + cd .. +}