#!/usr/bin/env bash
set -euo pipefail

game_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
launcher="$game_dir/.stardew-modsync/unix/launch-stardew"
smapi="$game_dir/StardewModdingAPI"

if [[ -x "$launcher" ]]; then
  exec "$launcher" "$@"
fi

echo "Thor's Fjord launcher is temporarily unavailable; launching the installed SMAPI directly." >&2
if [[ -x "$smapi" ]]; then
  exec "$smapi" "$@"
fi

echo "Installed SMAPI launcher is missing or not executable: $smapi" >&2
exit 1
