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

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
JAR_PATH="$SCRIPT_DIR/Fate-RSPS.jar"

if ! command -v java >/dev/null 2>&1; then
  echo "Java was not found on this system."
  echo
  echo "Fedora install command:"
  echo "  sudo dnf install java-17-openjdk java-17-openjdk-headless"
  echo
  echo "Then run this launcher again."
  exit 1
fi

if [ ! -f "$JAR_PATH" ]; then
  echo "Missing client jar:"
  echo "  $JAR_PATH"
  exit 1
fi

cd "$SCRIPT_DIR"
exec java -Xms512m -Xmx2048m -jar "$JAR_PATH" "$@"
