SubServers-2/SubServers.Creator/Purpur/build.sh
ME1312 ba80e0a16a
Folia scheduling support
Plugins that depend on SubServers.Client can make use of our platform-`AgnosticScheduler` to achieve the same results
2023-04-09 04:25:30 -04:00

52 lines
1.2 KiB
Bash

# SubCreator Purpur Build Script
#
#!/usr/bin/env bash
if [[ -z "$version" ]]
then
echo ERROR: No Build Version Supplied
rm -Rf "$0"
exit 1
fi
function __DL() {
if [[ -x "$(command -v wget)" ]]; then
wget -O "$1" "$2"; return $?
else
curl -Lo "$1" "$2"; return $?
fi
}
function __Restore() {
if [[ -f "Purpur.old.jar" ]]; then
if [[ -f "Purpur.jar" ]]; then
rm -Rf Purpur.jar
fi
mv Purpur.old.jar Purpur.jar
fi
}
echo Downloading Purpur...
if [[ -f "Purpur.jar" ]]; then
if [[ -f "Purpur.old.jar" ]]; then
rm -Rf Purpur.old.jar
fi
mv Purpur.jar Purpur.old.jar
fi
__DL Purpur.jar "https://api.purpurmc.org/v2/purpur/$version/latest/download"; __RETURN=$?
if [[ $__RETURN -eq 0 ]]; then
if [[ $(stat -c%s "Purpur.jar") -ge 1000000 ]]; then
echo Cleaning Up...
rm -Rf "$0"
exit 0
else
echo ERROR: Received invalid jarfile when requesting Purpur version $version:
cat Purpur.jar
printf "\n"
__Restore
rm -Rf "$0"
exit 4
fi
else
echo ERROR: Failed downloading Purpur. Is PurpurMC.org down?
__Restore
rm -Rf "$0"
exit 3
fi
exit 2