diff options
Diffstat (limited to 'mcsh.sh')
| -rwxr-xr-x | mcsh.sh | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -8,19 +8,19 @@ NATIVES_DIR="natives" ASSETS_DIR="assets" GAME_DIR="run" -VERSION="1.21.8" - function update_metadata ( printf 'updating version manifest\n' >&2 mkdir -p "$VERSIONS_DIR" curl --silent "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" | jq '{"latest": .latest, "versions": [.versions[] | {"key": .id, "value": .url}] | from_entries}' > "$VERSIONS_DIR/manifest.json" - printf 'updating %s meta %s\n' "$VERSION" >&2 - mkdir -p "$VERSIONS_DIR/$VERSION" - curl --silent -o "$VERSIONS_DIR/$VERSION/meta.json" "$(jq -r --arg version "$VERSION" '.versions[$version]' $VERSIONS_DIR/manifest.json)" - meta="$(jq -c --slurpfile info info.json --slurpfile auth auth.json -f meta.jq "$VERSIONS_DIR/$VERSION/meta.json")" + version="${1:-"$(jq -r '.latest.release' "$VERSIONS_DIR/manifest.json")"}" + + printf 'updating %s meta %s\n' "$version" >&2 + mkdir -p "$VERSIONS_DIR/$version" + curl --silent -o "$VERSIONS_DIR/$version/meta.json" "$(jq -r --arg version "$version" '.versions[$version]' $VERSIONS_DIR/manifest.json)" + meta="$(jq -c --slurpfile info info.json --slurpfile auth auth.json -f meta.jq "$VERSIONS_DIR/$version/meta.json")" - printf 'updating %s asset index...\n' "$VERSION" >&2 + printf 'updating %s asset index...\n' "$version" >&2 mkdir -p "$ASSETS_DIR/indexes" assets_url="$(<<<"$meta" jq -r '.asset_index')" curl --silent -o "$ASSETS_DIR/indexes/$(basename "$assets_url")" "$assets_url" @@ -29,7 +29,7 @@ function update_metadata ( ) function launch ( - meta="$(update_metadata)" + meta="$(update_metadata "${1:-}")" export LIBRARIES_DIR function download_library { @@ -52,9 +52,10 @@ function launch ( export -f download_asset #TODO: check hash - if ! [[ -e "$VERSIONS_DIR/$VERSION/client.jar" ]]; then - printf 'downloading %s client jar...\n' "$VERSION" >&2 - <<<"$meta" jq -r '.client_url' | xargs curl --silent -o "$VERSIONS_DIR/$VERSION/client.jar" + version="$(<<<"$meta" jq -r '.version')" + if ! [[ -e "$VERSIONS_DIR/$version/client.jar" ]]; then + printf 'downloading %s client jar...\n' "$version" >&2 + <<<"$meta" jq -r '.client_url' | xargs curl --silent -o "$VERSIONS_DIR/$version/client.jar" fi printf 'downloading libraries...\n' >&2 @@ -63,9 +64,9 @@ function launch ( printf 'downloading assets...\n' >&2 jq -r '.objects | to_entries[] | "\(.key) \(.value.hash[:2])/\(.value.hash)"' "$ASSETS_DIR/indexes/$(basename "$(<<<"$meta" jq -r '.asset_index')")" | xargs -P 10 -I {} "$SHELL" -c "download_asset {}" - # if ! [[ -e "$VERSIONS_DIR/$VERSION/log4j.xml" ]]; then - # printf 'downloading %s log4j config...\n' "$VERSION" >&2 - # <<<"$meta" jq -r '.logging_config' | xargs curl --silent -o "$VERSIONS_DIR/$VERSION/log4j.xml" + # if ! [[ -e "$VERSIONS_DIR/$version/log4j.xml" ]]; then + # printf 'downloading %s log4j config...\n' "$version" >&2 + # <<<"$meta" jq -r '.logging_config' | xargs curl --silent -o "$VERSIONS_DIR/$version/log4j.xml" # fi function replace_placeholders { @@ -81,4 +82,4 @@ function launch ( <<<"$meta" jq -r '.args.jvm + [.main_class] + .args.game | join(" ")' | replace_placeholders | xargs java ) -launch +launch "${1:-}" |