3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 02:50:09 +01:00

Update scripts for NMS repackaging

Dieser Commit ist enthalten in:
jmp 2021-03-16 00:19:21 -07:00 committet von Mariell Hoversholm
Ursprung d4532f7e70
Commit b28d461145
3 geänderte Dateien mit 20 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -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."

Datei anzeigen

@ -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

Datei anzeigen

@ -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 <auto@mated.null>"
# 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 <auto@mated.null>"