Last active
March 20, 2021 15:48
-
-
Save NoozAbooz/66dfbcb0d4cdc98a813eddb2a23c2c1e to your computer and use it in GitHub Desktop.
MC Java lwjgl checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function error { | |
| echo -e "\e[91m$1\e[39m" | |
| exit 1 | |
| } | |
| while true;do | |
| #exit if multiple scripts running | |
| scriptlist="$(ps aux | grep "$(basename "$0")" | grep bash | grep -v grep)" | |
| numscripts="$(echo "$scriptlist" | wc -l)" | |
| if [ "$numscripts" -gt 2 ];then | |
| echo "multiple $(basename "$0") scripts running. Exiting now." | |
| echo "$scriptlist" | |
| exit 0 | |
| fi | |
| #get every file matching instance.json in instances folder | |
| files="$(find ~/Minecraft/ATLauncher/instances -name instance.json)" | |
| PREIFS="$IFS" | |
| IFS=$'\n' | |
| #loop that operates on one file at a time | |
| for file in $files ;do | |
| #determine what minecraft version each file runs | |
| version="$(cat "$file" | grep ' "version":' | head -n1 | awk '{print $2}' | tr -d '", ')" | |
| #exit if version variable empty | |
| [ -z "$version" ] && error "minecraft-parser.sh: Failed to determine version for $file file!" | |
| echo -n "${version}: " | |
| #if version less than 1.13.0 | |
| if [ "$(echo -e "1.13.0\n${version}.0" | sort -V | head -n1)" = "1.13.0" ]; then | |
| echo "Greater than or equal to 1.13.0" | |
| echo "Nothing to do" | |
| else | |
| echo "Less than 1.13.0" | |
| echo "Enabling lwjgl2arm32..." | |
| if cat "$file" | grep -q lwjgl2arm32;then | |
| true | |
| echo "lwjgl2arm32 already found in $file" | |
| elif cat "$file" | grep -q javaArguments;then | |
| #javaArguments found, so just add it there | |
| echo "javaArguments found in $file, so just adding lwjgl2arm32..." | |
| sed -i 's? "javaArguments": "? "javaArguments": "-Dorg.lwjgl.librarypath='$HOME'/lwjgl2arm32 ?g' "$file" | |
| else | |
| #no javaArguments found, so create it | |
| echo "no javaArguments found in $file, so creating it..." | |
| sed -i 's? "launcher": {? "launcher": {\n "javaArguments": "-Dorg.lwjgl.librarypath='$HOME'/lwjgl2arm32 -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M",?g' "$file" | |
| fi | |
| fi | |
| done | |
| IFS="$PREIFS" | |
| sleep 10 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment