diff --git a/scripts/decompile.sh b/scripts/decompile.sh index a1b06a1f1d..d90a6de9da 100755 --- a/scripts/decompile.sh +++ b/scripts/decompile.sh @@ -73,7 +73,7 @@ if [ ! -d "$classdir" ]; then mkdir -p "$classdir" cd "$classdir" set +e - jar xf "$decompiledir/$minecraftversion-mapped.jar" net/minecraft/server + jar xf "$decompiledir/$minecraftversion-mapped.jar" net/minecraft if [ "$?" != "0" ]; then cd "$basedir" echo "Failed to extract NMS classes." diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 0051a75308..597f797c1f 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -2,7 +2,7 @@ ( set -e -nms="net/minecraft/server" +nms="net/minecraft" export MODLOG="" PS1="$" basedir="$(cd "$1" && pwd -P)" @@ -24,6 +24,7 @@ function import { if [[ ! -f "$target" ]]; then export MODLOG="$MODLOG Imported $file from mc-dev\n"; #echo "Copying $base to $target" + mkdir -p "$(dirname "$target")" cp "$base" "$target" || exit 1 else echo "UN-NEEDED IMPORT: $file" @@ -59,10 +60,9 @@ function importLibrary { ) +files=$(cat "$basedir/Spigot-Server-Patches/"* | grep "+++ b/src/main/java/net/minecraft/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\///g') -files=$(cat "$basedir/Spigot-Server-Patches/"* | grep "+++ b/src/main/java/net/minecraft/server/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') - -nonnms=$(grep -R "new file mode" -B 1 "$basedir/Spigot-Server-Patches/" | grep -v "new file mode" | grep -oE "net\/minecraft\/server\/.*.java" | grep -oE "[A-Za-z]+?.java$" --color=none | sed 's/.java//g') +nonnms=$(grep -R "new file mode" -B 1 "$basedir/Spigot-Server-Patches/" | grep -v "new file mode" | grep -oE "net\/minecraft\/**\/.*.java" | grep -oE "[A-Za-z]+?.java$" --color=none | sed 's/.java//g') function containsElement { local e for e in "${@:2}"; do @@ -74,7 +74,8 @@ set +e for f in $files; do containsElement "$f" ${nonnms[@]} if [ "$?" == "1" ]; then - if [ ! -f "$workdir/Spigot/Spigot-Server/src/main/java/net/minecraft/server/$f.java" ]; then + if [ ! -f "$workdir/Spigot/Spigot-Server/src/main/java/net/minecraft/$f" ]; then + f="$(echo "$f" | sed 's/.java//g')" if [ ! -f "$decompiledir/$nms/$f.java" ]; then echo "$(color 1 31) ERROR!!! Missing NMS$(color 1 34) $f $(colorend)"; else diff --git a/scripts/init.sh b/scripts/init.sh index 3b85343d6c..9c51762ae6 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -7,8 +7,8 @@ basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) spigotdecompiledir="$workdir/Minecraft/$minecraftversion/spigot" -nms="$spigotdecompiledir/net/minecraft/server" -cb="src/main/java/net/minecraft/server" +nms="$spigotdecompiledir" +cb="src/main/java" gitcmd="git -c commit.gpgsign=false" # https://stackoverflow.com/a/38595160 @@ -45,31 +45,31 @@ done echo "Applying CraftBukkit patches to NMS..." cd "$workdir/CraftBukkit" $gitcmd checkout -B patched HEAD >/dev/null 2>&1 -rm -rf "$cb" -mkdir -p "$cb" +rm -rf "$cb/net" # create baseline NMS import so we can see diff of what CB changed -for file in $(ls nms-patches) +while IFS= read -r -d '' file do - patchFile="nms-patches/$file" - file="$(echo "$file" | cut -d. -f1).java" + patchFile="$file" + file="$(echo "$file" | cut -d "/" -f2- | cut -d. -f1).java" + mkdir -p "$(dirname $cb/"$file")" cp "$nms/$file" "$cb/$file" -done +done < <(find nms-patches -type f -print0) $gitcmd add src $gitcmd commit -m "Minecraft $ $(date)" --author="Vanilla " # apply patches -for file in $(ls nms-patches) +while IFS= read -r -d '' file do - patchFile="nms-patches/$file" - file="$(echo "$file" | cut -d. -f1).java" + patchFile="$file" + file="$(echo "$file" | cut -d "/" -f2- | cut -d. -f1).java" echo "Patching $file < $patchFile" set +e strip_cr "$nms/$file" > /dev/null set -e - "$patch" -s -d src/main/java/ "net/minecraft/server/$file" < "$patchFile" -done + "$patch" -d src/main/java -p 1 < "$patchFile" +done < <(find nms-patches -type f -print0) $gitcmd add src $gitcmd commit -m "CraftBukkit $ $(date)" --author="CraftBukkit "