#!/bin/bash set -euo pipefail # Standalone macOS launcher. No system Java install, sudo, or account tokens. SOURCE_COMMIT='03ac7fa5864429f5e8719097f41cb7e2eebfc5a4' SOURCE_SHA256='b90def96d4b337cd6463336e21aa3b0750180c9f0a9d5ac090c25158bb058c84' SOURCE_URL="https://codeload.github.com/11jfreeman11/OSRS-Bank-Slot-Borders/zip/$SOURCE_COMMIT" DATA_DIR="${BANK_GRID_DATA_DIR:-$HOME/Library/Application Support/BankSlotBorders}" on_exit() { result=$? if [ "$result" -ne 0 ]; then printf '\nSetup or launch failed. Files are kept in:\n%s\n' "$DATA_DIR" >&2 printf 'Share the error above with the author; never share login codes or account tokens.\n' >&2 if [ -t 0 ]; then read -r -p 'Press Return to close this window. ' ignored || true; fi fi } trap on_exit EXIT verified_download() { local url="$1" destination="$2" expected="$3" actual if [ -f "$destination" ]; then actual=$(/usr/bin/shasum -a 256 "$destination" | /usr/bin/awk '{print $1}') if [ "$actual" = "$expected" ]; then return; fi printf 'Cached file failed verification: %s. Rename it and retry.\n' "$destination" >&2 return 1 fi /usr/bin/curl --fail --location --retry 3 --proto '=https' --tlsv1.2 "$url" -o "$destination.part" actual=$(/usr/bin/shasum -a 256 "$destination.part" | /usr/bin/awk '{print $1}') if [ "$actual" != "$expected" ]; then printf 'Download failed its SHA-256 check; it will not be used.\n' >&2 return 1 fi /bin/mv -f "$destination.part" "$destination" } if [ "$(/usr/bin/uname -s)" != 'Darwin' ]; then printf 'This launcher is for macOS. Use the Windows download on Windows.\n' >&2 exit 1 fi MAC_ARCH=$(/usr/bin/uname -m) # Detect Apple hardware even if Terminal itself is running under Rosetta. if [ "$MAC_ARCH" = 'arm64' ] || [ "$(/usr/sbin/sysctl -n hw.optional.arm64 2>/dev/null || true)" = '1' ]; then JAVA_ARCH='aarch64' JAVA_SHA256='c487a1c3a56588b3a32d0d07cdd526bf3d401c4b8422be772ca178bfcd647f3f' elif [ "$MAC_ARCH" = 'x86_64' ]; then JAVA_ARCH='x64' JAVA_SHA256='03de26f0d11ec3e6365e0352d9fcfaff447be35a2b2f36ee1ffb6063980343f5' else printf 'Unsupported Mac architecture: %s\n' "$MAC_ARCH" >&2 exit 1 fi JAVA_URL="https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.32.1%2B1/OpenJDK11U-jdk_${JAVA_ARCH}_mac_hotspot_11.0.32.1_1.tar.gz" CACHE="$DATA_DIR/downloads" RUNTIME="$DATA_DIR/temurin-11.0.32.1-$JAVA_ARCH" SOURCE="$DATA_DIR/src-$SOURCE_COMMIT" /bin/mkdir -p "$CACHE" "$RUNTIME" "$SOURCE" printf '\nBANK SLOT BORDERS - Mac community test client\n' printf 'Selected Java architecture: %s\n' "$JAVA_ARCH" printf 'First start downloads Java, plugin source, Gradle and RuneLite. Keep this window open.\n\n' printf '[1/3] Checking portable Java (about 185 MB on first start)...\n' JAVA_ARCHIVE="$CACHE/temurin11-mac-$JAVA_ARCH.tar.gz" verified_download "$JAVA_URL" "$JAVA_ARCHIVE" "$JAVA_SHA256" JAVA_HOME="$RUNTIME/jdk-11.0.32.1+1/Contents/Home" if [ ! -f "$RUNTIME/ready.txt" ]; then /usr/bin/tar -xzf "$JAVA_ARCHIVE" -C "$RUNTIME" test -x "$JAVA_HOME/bin/java" printf '%s\n' "$JAVA_SHA256" > "$RUNTIME/ready.txt" fi if [ ! -x "$JAVA_HOME/bin/java" ]; then printf 'Java is missing or not executable. Please report this error to the author.\n' >&2 exit 1 fi export JAVA_HOME export PATH="$JAVA_HOME/bin:$PATH" export GRADLE_USER_HOME="$DATA_DIR/gradle" printf '[2/3] Checking the published plugin source...\n' SOURCE_ARCHIVE="$CACHE/$SOURCE_COMMIT.zip" verified_download "$SOURCE_URL" "$SOURCE_ARCHIVE" "$SOURCE_SHA256" PROJECT="$SOURCE/OSRS-Bank-Slot-Borders-$SOURCE_COMMIT" if [ ! -f "$SOURCE/ready.txt" ]; then /usr/bin/unzip -q -o "$SOURCE_ARCHIVE" -d "$SOURCE" test -f "$PROJECT/gradlew" printf '%s\n' "$SOURCE_COMMIT" > "$SOURCE/ready.txt" fi if [ "${BANK_GRID_PREPARE_ONLY:-0}" = '1' ]; then printf 'Preparation complete. RuneLite was not launched.\n' exit 0 fi printf '[3/3] Building and opening RuneLite...\n' printf 'Enable Bank Slot Borders in plugin settings.\n' printf 'Jagex accounts: use the Jagex auth sidebar > Add Jagex Account, select a character, then Play Now.\n' cd "$PROJECT" /bin/bash ./gradlew run --no-daemon