2016-04-02 03:55:54 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-12-30 04:40:32 +00:00
|
|
|
|
2016-04-03 07:23:19 +00:00
|
|
|
(
|
|
|
|
set -e
|
2015-12-30 04:40:32 +00:00
|
|
|
PS1="$"
|
2016-04-03 08:35:51 +00:00
|
|
|
basedir="$(cd "$1" && pwd -P)"
|
2016-04-02 03:55:54 +00:00
|
|
|
workdir="$basedir/work"
|
2016-11-20 21:58:20 +00:00
|
|
|
minecraftversion=$(cat "${workdir}/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
|
|
|
minecrafthash=$(cat "${workdir}/BuildData/info.json" | grep minecraftHash | cut -d '"' -f 4)
|
|
|
|
accesstransforms="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep accessTransforms | cut -d '"' -f 4)
|
|
|
|
classmappings="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep classMappings | cut -d '"' -f 4)
|
|
|
|
membermappings="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep memberMappings | cut -d '"' -f 4)
|
|
|
|
packagemappings="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep packageMappings | cut -d '"' -f 4)
|
2017-08-12 23:56:59 +00:00
|
|
|
jarpath="$workdir/Minecraft/$minecraftversion/$minecraftversion"
|
2015-12-30 04:40:32 +00:00
|
|
|
|
|
|
|
echo "Downloading unmapped vanilla jar..."
|
|
|
|
if [ ! -f "$jarpath.jar" ]; then
|
2017-08-12 23:56:59 +00:00
|
|
|
mkdir -p "$workdir/Minecraft/$minecraftversion"
|
2015-12-30 04:40:32 +00:00
|
|
|
curl -s -o "$jarpath.jar" "https://s3.amazonaws.com/Minecraft.Download/versions/$minecraftversion/minecraft_server.$minecraftversion.jar"
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to download the vanilla server jar. Check connectivity or try again later."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-12-30 05:55:44 +00:00
|
|
|
# OS X doesn't have md5sum, just md5 -r
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
shopt -s expand_aliases
|
|
|
|
alias md5sum='md5 -r'
|
|
|
|
echo "Using an alias for md5sum on OS X"
|
|
|
|
fi
|
|
|
|
|
2015-12-30 04:40:32 +00:00
|
|
|
checksum=$(md5sum "$jarpath.jar" | cut -d ' ' -f 1)
|
|
|
|
if [ "$checksum" != "$minecrafthash" ]; then
|
|
|
|
echo "The MD5 checksum of the downloaded server jar does not match the BuildData hash."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Applying class mappings..."
|
|
|
|
if [ ! -f "$jarpath-cl.jar" ]; then
|
2016-04-02 03:55:54 +00:00
|
|
|
java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map -i "$jarpath.jar" -m "$classmappings" -o "$jarpath-cl.jar" 1>/dev/null
|
2015-12-30 04:40:32 +00:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to apply class mappings."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Applying member mappings..."
|
|
|
|
if [ ! -f "$jarpath-m.jar" ]; then
|
2016-04-02 03:55:54 +00:00
|
|
|
java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map -i "$jarpath-cl.jar" -m "$membermappings" -o "$jarpath-m.jar" 1>/dev/null
|
2015-12-30 04:40:32 +00:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to apply member mappings."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating remapped jar..."
|
|
|
|
if [ ! -f "$jarpath-mapped.jar" ]; then
|
2016-04-02 03:55:54 +00:00
|
|
|
java -jar "$workdir/BuildData/bin/SpecialSource.jar" --kill-lvt -i "$jarpath-m.jar" --access-transformer "$accesstransforms" -m "$packagemappings" -o "$jarpath-mapped.jar" 1>/dev/null
|
2015-12-30 04:40:32 +00:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to create remapped jar."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Installing remapped jar..."
|
2016-04-02 03:55:54 +00:00
|
|
|
cd "$workdir/CraftBukkit" # Need to be in a directory with a valid POM at the time of install.
|
2015-12-30 04:40:32 +00:00
|
|
|
mvn install:install-file -q -Dfile="$jarpath-mapped.jar" -Dpackaging=jar -DgroupId=org.spigotmc -DartifactId=minecraft-server -Dversion="$minecraftversion-SNAPSHOT"
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to install remapped jar."
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-04-03 07:23:19 +00:00
|
|
|
)
|