X-Git-Url: https://git.slaskete.net/einar-bin/blobdiff_plain/5028e1e0668493bc43529a4f33d1530ae978e3df..aab3dc85472e1d7cb543095da12d0f52b584f275:/minecraft.sh?ds=sidebyside diff --git a/minecraft.sh b/minecraft.sh index 70b1bf6..007e147 100755 --- a/minecraft.sh +++ b/minecraft.sh @@ -18,38 +18,75 @@ # Released to the public under the WTFPL: http://sam.zoy.org/wtfpl/COPYING # CONFIG STUFF - change these to suit your system +# Minecraft home folder, where the binaries and saves and stuff are stored: MC_HOME="${HOME}/.minecraft" +# Location and filename for the Minecraft launcher jar: MC_LAUNCHER="${HOME}/bin/minecraft.jar" +# Command line to run to start Minecraft: MC_COMMAND="java -Xmx2048M -Xms1024M -cp ${MC_LAUNCHER} net.minecraft.LauncherFrame" # This might be needed to fix 64bit java on Linux (path to your 64bit java libs) # Uncomment this if not suitable. -export LD_LIBRARY_PATH="/usr/lib/jvm/jre/lib/amd64/" +export LD_LIBRARY_PATH="/usr/java/latest/lib/amd64/" # Here comes the code -if [ ${#} -ne 1 ]; then - echo "Usage: 'minecraft '" +UPDATEMC=0 + +if [ ${#} -lt 1 ]; then + echo "Usage: 'minecraft ' or 'minecraft --add '" + exit 1 +fi + +if [ "${1}" == "--add" ]; then + if [ "${#}" -ne 2 ]; then + echo "You must supply what version you are adding: 'minecraft --add '" + exit 1 + else + MC_NEW_FOLDER="${MC_HOME}/bin-${2}" + read -p "Will save new bin-folder called bin-${2}, press update when prompted." + UPDATEMC=1 + fi +fi + +if [ -z ${MC_HOME} ]; then + echo "Minecraft home folder not set! Baaaad idea!" exit 1 fi -MC_VERSION_FOLDER="${MC_HOME}/bin-${1}" +if [ ! -d ${MC_HOME} ]; then + echo "Minecraft home folder (${MC_HOME}) not found!" + exit 1 +fi + +if [ ${UPDATEMC} -ne 1 ]; then + MC_VERSION_FOLDER="${MC_HOME}/bin-${1}" +else + MC_VERSION_FOLDER=$(ls -d ${MC_HOME}/bin-* | tail -n 1) +fi + MC_WORKING_FOLDER="${MC_HOME}/bin" if [ ! -d "${MC_VERSION_FOLDER}" ]; then - echo "Could not find that version folder." + echo "Could not find that version folder (${MC_VERSION_FOLDER})" + echo -e "\nAvailable Minecraft versions are:" + echo "---------------------------------" + ls -d ${MC_HOME}/bin-* | cut -d "-" -f 2 exit 1 fi if [ -d "${MC_WORKING_FOLDER}" ]; then rm -rf ${MC_WORKING_FOLDER} elif [ ! -d "${MC_WORKING_FOLDER}" ]; then - echo "Minecraft bin folder is not a directory, bailing out." + echo "Minecraft bin folder (${MC_WORKING_FOLDER}) is not a directory, bailing out." exit 1 fi if [ ! -e "${MC_WORKING_FOLDER}" ]; then cp -r ${MC_VERSION_FOLDER} ${MC_WORKING_FOLDER} ${MC_COMMAND} + if [ ${UPDATEMC} == 1 ]; then + cp -r ${MC_WORKING_FOLDER} ${MC_NEW_FOLDER} + fi fi