-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.sh
171 lines (152 loc) · 6.25 KB
/
launch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# Minecraft: Pi Edition: Reborn Bash Launcher
# Copyright (C) 2022 bsX
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
launcherversion="1.01"
launcherPformat="1"
bld=$(tput bold) # Bold
red=$(tput setaf 1) # Red
grn=$(tput setaf 2) # Green
ylw=$(tput setaf 3) # Yellow
blu=$(tput setaf 4) # Blue
pur=$(tput setaf 5) # Purple
cyn=$(tput setaf 6) # Cyan
wht=$(tput setaf 7) # White
rst=$(tput sgr0) # Text reset
function updater() {
# Download the ZSYNC file from TheBrokenRail's servers
if [ "$updateserver" = "mcpipp" ]; then
wget -q -O mcpi.zsync "https://github.com/NoozSBC/mcpi-reborn-extended/releases/latest/download/minecraft-pi-reborn-client-$cpuarch.AppImage.zsync"
else
wget -q -O mcpi.zsync "https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/minecraft-pi-reborn-client-latest-$cpuarch.AppImage.zsync"
fi
# Retrieve the first 2 lines of data from the zsync file.
zsync_out=`grep -a -A1 zsync mcpi.zsync`
# For reference: -a tells it to output binary data like it's a text file, since only part of a zsync file contains actual text information (and that's all we need)
# -A1 zsync tells it to find the line with "zsync" in it, and output that line and the next line of data
# We're excluding the rest of the lines since this is only needed to get the current release of mcpi-r
# Remove our ZSYNC file
rm -rf mcpi.zsync
# Cut the first line out of the string, we don't need it
zsync_out=$(echo "$zsync_out" | sed 1d)
# Strip the Zsync variable identifier
zsync_out=${zsync_out//Filename: /}
# Check if we already have this game version
ver_check=`ls $zsync_out`
if [ "$ver_check" != "$zsync_out" ]
then
# Tell the user what we're doing
echo ""
echo "Your MCPI-Reborn version is outdated. Updating..."
echo ""
# Move any existing mcpi AppImages to a temporary folder
mkdir -p "old"
mv -i minecraft-pi-reborn-client-*.AppImage "old"
# Download the game AppImage
if [ "$updateserver" = "mcpipp" ]; then
wget -q "https://github.com/NoozSBC/mcpi-reborn-extended/releases/latest/download/$zsync_out"
else
wget -q "https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/$zsync_out"
fi
# Set the game AppImage executable
chmod +x $zsync_out
fi
}
echo ""
echo "Minecraft: Pi Edition: Reborn Bash Launcher
Copyright (C) 2022 bsX
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>."
echo ""
# Open the configuration script if the user hasn't configured their game yet
cfg_check=`ls config.bcfg`
if [ "$cfg_check" != "config.bcfg" ]
then
# Set a variable so that the configuration script doesn't bark at the user for resetting their configuration (which is nonexistant)
cfg_new="1"
. configure.sh
fi
. config.bcfg
# Check for command-line arguments
if [[ "$1" == "--help" || "$1" == "-h" ]];
then
echo "bMCPIL Help:"
echo ""
echo "Arguments: ./launch.sh [preset]"
echo ""
exit
elif [ ! -z "$1" ]; # If a non-null, none flag argument was passed, treat it as a preset
then
preset_check=`ls ./presets/$1`
if [ "$preset_check" != "./presets/$1" ] # Make sure the preset specified actually exists
then
echo "${red}[Error] Unknown preset specified from the command line [$1]. Loading from default.${rst}"
. ./presets/default
else
presetsel="$1" # Overwrite the preset set in the config
fi
fi
# Check if the user's selected preset actually exists. If not, load the default
preset_check=`ls ./presets/$presetsel`
if [ "$preset_check" != "./presets/$presetsel" ]
then
echo "${red}[Error] Unknown preset [$presetsel], please reconfigure your game. Loading from normal.${rst}"
. ./presets/normal
else
. ./presets/$presetsel
fi
if [[ "$enableupdater" == "false" ]];
then
game_check=`ls minecraft-pi-reborn-client-*.AppImage`
if [ "$game_check" == "" ]
then
echo "${red}[Error] Can't find MCPI AppImage. Try enabling the updater in your config.${rst}"
fi
else
updater
fi
if [[ "$enableskins" != "false" ]];
then
if [ -d ~/.minecraft-pi/overrides/images/skins/.git/ ]; then
git -C ~/.minecraft-pi/overrides/images/skins/ pull https://github.com/bsx-gh/bMCPIL-skins.git
elif [ -d ~/.minecraft-pi/overrides/images/skins/ ]; then
mv ~/.minecraft-pi/overrides/images/skins/ ~/.minecraft-pi/overrides/images/skins-old/
git clone --quiet https://github.com/bsx-gh/bMCPIL-skins.git ~/.minecraft-pi/overrides/images/skins/
else
git clone --quiet https://github.com/bsx-gh/bMCPIL-skins.git ~/.minecraft-pi/overrides/images/skins/
fi
fi
if [[ "$usedefaultflags" == "true" ]]; then
MCPI_RENDER_DISTANCE="$renderdistance" MCPI_USERNAME="$username" ./minecraft-pi-reborn-client-*.AppImage --default --no-cache
elif [[ "$askonlaunch" == "true" ]]; then
MCPI_RENDER_DISTANCE="$renderdistance" MCPI_USERNAME="$username" ./minecraft-pi-reborn-client-*.AppImage --no-cache
elif [[ "$normallaunch" == "true" ]]; then
MCPI_RENDER_DISTANCE="$renderdistance" MCPI_USERNAME="$username" ./minecraft-pi-reborn-client-*.AppImage
else
MCPI_FEATURE_FLAGS="$preset" MCPI_RENDER_DISTANCE="$renderdistance" MCPI_USERNAME="$username" ./minecraft-pi-reborn-client-*.AppImage --no-cache
fi
echo ""
if [[ "$asktoexit" == "true" ]];
then
read -p "Press [Enter] to close the program."
fi