PaperMC/paper-server/applyPatches.sh

39 lines
829 B
Bash
Raw Normal View History

#!/bin/bash
2021-03-15 23:00:00 +01:00
set -euo pipefail
if [ -z "$1" ]
then
echo "Please run this script again with the clean decompile sources as an argument. In most cases this will be ../work/decompile-XXXX"
exit
fi
# https://stackoverflow.com/a/38595160
# https://stackoverflow.com/a/800644
if sed --version >/dev/null 2>&1; then
strip_cr() {
sed -i -- "s/\r//" "$@"
}
else
strip_cr () {
sed -i "" "s/$(printf '\r')//" "$@"
}
fi
2021-03-15 23:00:00 +01:00
nms=$1
cb=src/main/java
#clean up and rebuild
2021-03-15 23:00:00 +01:00
rm -rf $cb/net
for file in $(find nms-patches -type f -printf '%P\n')
do
2021-03-15 23:00:00 +01:00
patchFile="$file"
file="$(echo $file | cut -d. -f1).java"
echo "Patching $file < $patchFile"
strip_cr "$nms/$file" > /dev/null
2021-03-15 23:00:00 +01:00
mkdir -p $(dirname $cb/$file)
cp "$nms/$file" "$cb/$file"
2021-03-15 23:00:00 +01:00
patch -d src/main/java -p 1 < "nms-patches/$patchFile"
done