2016-04-02 05:55:54 +02:00
|
|
|
#!/usr/bin/env bash
|
2015-12-30 05:40:32 +01:00
|
|
|
|
2016-04-03 09:23:19 +02:00
|
|
|
(
|
|
|
|
set -e
|
2015-12-30 05:40:32 +01:00
|
|
|
PS1="$"
|
2016-04-03 10:35:51 +02:00
|
|
|
basedir="$(cd "$1" && pwd -P)"
|
2016-04-02 05:55:54 +02:00
|
|
|
workdir="$basedir/work"
|
2021-03-16 17:35:55 +01:00
|
|
|
revision="$(cat "$basedir"/revision.txt | tr -d '\n')"
|
|
|
|
minecraftversion="$(cat "${workdir}/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)"
|
2018-07-15 03:53:17 +02:00
|
|
|
minecraftserverurl=$(cat "${workdir}/BuildData/info.json" | grep serverUrl | cut -d '"' -f 4)
|
2016-11-20 22:58:20 +01:00
|
|
|
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)
|
2018-09-01 00:56:57 +02:00
|
|
|
decompiledir="$workdir/Minecraft/$minecraftversion"
|
|
|
|
jarpath="$decompiledir/$minecraftversion"
|
|
|
|
mkdir -p "$decompiledir"
|
2015-12-30 05:40:32 +01:00
|
|
|
|
|
|
|
echo "Downloading unmapped vanilla jar..."
|
|
|
|
if [ ! -f "$jarpath.jar" ]; then
|
2018-07-15 03:53:17 +02:00
|
|
|
curl -s -o "$jarpath.jar" "$minecraftserverurl"
|
2015-12-30 05:40:32 +01:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to download the vanilla server jar. Check connectivity or try again later."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-02-22 11:43:31 +01:00
|
|
|
# OS X & FreeBSD don't have md5sum, just md5 -r
|
2018-02-24 01:58:45 +01:00
|
|
|
command -v md5sum >/dev/null 2>&1 || {
|
|
|
|
command -v md5 >/dev/null 2>&1 && {
|
|
|
|
shopt -s expand_aliases
|
|
|
|
alias md5sum='md5 -r'
|
|
|
|
echo "md5sum command not found, using an alias instead"
|
|
|
|
} || {
|
|
|
|
echo >&2 "No md5sum or md5 command found"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
2015-12-30 06:55:44 +01:00
|
|
|
|
2015-12-30 05:40:32 +01: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
|
|
|
|
|
2021-03-16 17:35:55 +01:00
|
|
|
# These specialsource commands are from https://hub.spigotmc.org/stash/projects/SPIGOT/repos/builddata/browse/info.json
|
2015-12-30 05:40:32 +01:00
|
|
|
echo "Applying class mappings..."
|
2021-03-16 17:35:55 +01:00
|
|
|
if [ ! -f "$jarpath-$revision-cl.jar" ]; then
|
2021-03-16 17:39:56 +01:00
|
|
|
java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map --only . --only net/minecraft --only com/mojang/math --auto-lvt BASIC --auto-member SYNTHETIC -i "$jarpath.jar" -m "$classmappings" -o "$jarpath-$revision-cl.jar" 1>/dev/null
|
2015-12-30 05:40:32 +01:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to apply class mappings."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Applying member mappings..."
|
2021-03-16 17:35:55 +01:00
|
|
|
if [ ! -f "$jarpath-$revision-m.jar" ]; then
|
2021-03-16 17:39:56 +01:00
|
|
|
java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map --only . --only net/minecraft --only com/mojang/math --auto-member LOGGER --auto-member TOKENS -i "$jarpath-$revision-cl.jar" -m "$membermappings" -o "$jarpath-$revision-m.jar" 1>/dev/null
|
2015-12-30 05:40:32 +01:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to apply member mappings."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating remapped jar..."
|
2021-03-16 17:35:55 +01:00
|
|
|
if [ ! -f "$jarpath-$revision-mapped.jar" ]; then
|
2021-03-16 17:39:56 +01:00
|
|
|
java -jar "$workdir/BuildData/bin/SpecialSource.jar" --only . --only net/minecraft --only com/mojang/math -i "$jarpath-$revision-m.jar" --access-transformer "$accesstransforms" -m "$packagemappings" -o "$jarpath-$revision-mapped.jar" 1>/dev/null
|
2015-12-30 05:40:32 +01:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to create remapped jar."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Installing remapped jar..."
|
2016-04-02 05:55:54 +02:00
|
|
|
cd "$workdir/CraftBukkit" # Need to be in a directory with a valid POM at the time of install.
|
2021-03-16 17:35:55 +01:00
|
|
|
mvn install:install-file -q -Dfile="$jarpath-$revision-mapped.jar" -Dpackaging=jar -DgroupId=io.papermc -DartifactId=minecraft-server -Dversion="$minecraftversion-$revision-SNAPSHOT"
|
2015-12-30 05:40:32 +01:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to install remapped jar."
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-04-03 09:23:19 +02:00
|
|
|
)
|