From ce32154f65b75f32877e53b5e41e7f9c749d2b90 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 3 Sep 2018 19:55:14 -0400 Subject: [PATCH] [CI-SKIP] Download mojang libraries sources so we can modify them --- scripts/decompile.sh | 39 +++++++++++++++++++++++++++++++++++++++ scripts/importmcdev.sh | 24 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/scripts/decompile.sh b/scripts/decompile.sh index 8a9850e6db..12d5b075fc 100755 --- a/scripts/decompile.sh +++ b/scripts/decompile.sh @@ -20,7 +20,46 @@ forgefloweroptions="-dgs=1 -hdc=0 -asc=1 -udv=1 -jvn=1" forgeflowercachefile="$decompiledir/forgeflowercache" forgeflowercachevalue="$forgeflowerurl - $forgeflowerversion - $forgefloweroptions"; classdir="$decompiledir/classes" +versionjson="$workdir/Minecraft/$minecraftversion/$minecraftversion.json" +if [ ! -f "$versionjson" ]; then + echo "Downloading $minecraftversion JSON Data" + verescaped=$(echo ${minecraftversion} | sed 's/\./\\./g') + jsonurl=$(curl -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | grep -oE "https://.*?${verescaped}.json") + curl -o "$versionjson" "$jsonurl" + echo "$versionjson - $jsonurl" +fi + +function downloadLibraries { + group=$1 + groupesc=$(echo ${group} | sed 's/\./\\./g') + grouppath=$(echo ${group} | sed 's/\./\//g') + libdir="$decompiledir/libraries/${group}/" + mkdir -p "$libdir" + shift + for lib in "$@" + do + jar="$libdir/${lib}-sources.jar" + destlib="$libdir/${lib}" + if [ ! -f "$jar" ]; then + libesc=$(echo ${lib} | sed 's/\./\\]./g') + ver=$(grep -oE "${groupesc}:${libesc}:[0-9\.]+" "$versionjson" | sed "s/${groupesc}:${libesc}://g") + echo "Downloading ${group}:${lib}:${ver} Sources" + curl -s -o "$jar" "https://libraries.minecraft.net/${grouppath}/${lib}/${ver}/${lib}-${ver}-sources.jar" + set +e + grep "" "$jar" && grep -oE ".*?" "$jar" && rm "$jar" && echo "Failed to download $jar" && exit 1 + set -e + fi + + if [ ! -d "$destlib/$grouppath" ]; then + echo "Extracting $group:$lib Sources" + mkdir -p "$destlib" + (cd "$destlib" && jar xf "$jar") + fi + done +} + +downloadLibraries "com.mojang" datafixerupper authlib brigadier # prep folders mkdir -p "$workdir/ForgeFlower" diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index d7c95d0ed4..2a806907c6 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -29,6 +29,26 @@ function import { fi } +function importLibrary { + group=$1 + lib=$2 + prefix=$3 + shift 3 + for file in "$@"; do + file="$prefix/$file" + target="$workdir/Spigot/Spigot-Server/src/main/java/${file}" + targetdir=$(dirname "$target") + mkdir -p "${targetdir}" + base="$workdir/Minecraft/$minecraftversion/libraries/${group}/${lib}/$file" + if [ ! -f "$base" ]; then + echo "Missing $base" + exit 1 + fi + export MODLOG="$MODLOG Imported $file from $lib\n"; + cp "$base" "$target" || exit 1 + done +} + ( cd "$workdir/Spigot/Spigot-Server/" lastlog=$($gitcmd log -1 --oneline) @@ -63,6 +83,10 @@ for f in $files; do fi done +# Import Libraries - these must always be mapped manually, no automatic stuff + + + # Temporarily add new NMS dev imports here before you run paper patch # but after you have paper rb'd your changes, remove the line from this file before committing. # we do not need any lines added to this file