[CI-SKIP] Download mojang libraries sources so we can modify them

This commit is contained in:
Aikar 2018-09-03 19:55:14 -04:00
parent 997190c3e0
commit f90c38b8f5
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
2 changed files with 63 additions and 0 deletions

View File

@ -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 "<html>" "$jar" && grep -oE "<title>.*?</title>" "$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"

View File

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