2022-11-09 05:42:09 -08:00
#!/usr/bin/env sh
2023-08-28 10:34:41 +10:00
# Colors
RED = $( tput setaf 1)
GREEN = $( tput setaf 2)
YELLOW = $( tput setaf 3)
POWDER_BLUE = $( tput setaf 153)
MAGENTA = $( tput setaf 5)
NORMAL = $( tput sgr0)
2023-04-08 05:08:03 -05:00
touch .mode
2022-11-09 05:42:09 -08:00
set -e
2023-08-28 10:34:41 +10:00
printf " ${ MAGENTA } Nomifactory CEu | Pack Mode Switcher ${ NORMAL } "
2022-11-09 05:42:09 -08:00
2023-04-08 05:08:03 -05:00
NORMAL_CFG = config-overrides/normal
EXPERT_CFG = config-overrides/expert
2022-11-09 05:42:09 -08:00
TARGET = ./config
2023-04-08 05:08:03 -05:00
CURRENT_MODE = " $( head .mode) "
CURRENT_MODE = ${ CURRENT_MODE : = "normal" }
2023-08-28 10:34:41 +10:00
# Check if config-overrides dir exists
if [ [ ! -d " ${ NORMAL_CFG } " ] ] || [ [ ! -d " ${ EXPERT_CFG } " ] ] ; then
printf " \n\n ${ RED } Could not find \`config-overrides\` directory! \nMake sure you are in the \`/minecraft\` directory of your instance! (The one containing \`/config\`) ${ NORMAL } \n "
printf " ${ YELLOW } Otherwise, if you are in the \`/minecraft\` directory, please try reinstalling the pack. ${ NORMAL } \n "
exit 1
fi
# Capitalise First Letter (only works in bash 4+)
[ " ${ BASH_VERSINFO :- 0 } " -ge 4 ] && CURRENT_MODE = ${ CURRENT_MODE ^ }
printf " \n\n ${ YELLOW } Current Mode: ${ CURRENT_MODE } ${ NORMAL } \n "
2022-11-09 05:42:09 -08:00
if [ -z " $1 " ] ; then
2023-08-28 10:34:41 +10:00
printf " ${ POWDER_BLUE } Set Pack Mode: [Normal / Expert]: ${ NORMAL } "
2022-11-09 05:42:09 -08:00
read MODE
else
MODE = " $1 "
fi
2023-04-08 05:08:03 -05:00
case $MODE in
2023-08-28 10:34:41 +10:00
N| n| normal| Normal)
2023-04-08 05:08:03 -05:00
cp -rf " $NORMAL_CFG /. " ${ TARGET }
# Only copy server.properties if it exists.
if [ -f "server.properties" ] ; then
mv " ${ TARGET } /server.properties " ./
else
2023-10-23 09:58:13 +02:00
rm " ${ TARGET } /server.properties " || true
2023-04-08 05:08:03 -05:00
fi
# Update Mode
echo normal > .mode
2022-11-09 05:42:09 -08:00
; ;
2023-08-28 10:34:41 +10:00
E| e| expert| Expert)
2023-04-08 05:08:03 -05:00
cp -rf " $EXPERT_CFG /. " ${ TARGET }
if [ -f "server.properties" ] ; then
mv " ${ TARGET } /server.properties " ./
else
2023-10-23 09:58:13 +02:00
rm " ${ TARGET } /server.properties " || true
2023-04-08 05:08:03 -05:00
fi
# Update Mode
echo expert > .mode
2022-11-09 05:42:09 -08:00
; ;
*)
2023-08-28 10:34:41 +10:00
printf " \n ${ RED } Error: Invalid input ${ MODE } ! ${ NORMAL } \n "
printf " \n ${ POWDER_BLUE } Accepted Inputs:\n ${ YELLOW } - [Normal, normal, N, n]\n- [Expert, expert, E, e] ${ NORMAL } \n "
2022-11-09 05:42:09 -08:00
exit 1
; ;
esac
2023-08-28 10:34:41 +10:00
printf " \n ${ GREEN } Complete! ${ NORMAL } \n "