2016-03-31 08:50:23 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-04-03 15:23:19 +08:00
|
|
|
(
|
|
|
|
set -e
|
2016-03-31 08:50:23 +08:00
|
|
|
nms="net/minecraft/server"
|
|
|
|
export MODLOG=""
|
|
|
|
PS1="$"
|
2016-04-03 16:35:51 +08:00
|
|
|
basedir="$(cd "$1" && pwd -P)"
|
2018-07-15 09:53:17 +08:00
|
|
|
source "$basedir/scripts/functions.sh"
|
2018-05-25 02:41:50 +08:00
|
|
|
gitcmd="git -c commit.gpgsign=false"
|
2016-03-31 08:50:23 +08:00
|
|
|
|
2016-04-02 11:55:54 +08:00
|
|
|
workdir="$basedir/work"
|
|
|
|
minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
2018-09-01 06:56:57 +08:00
|
|
|
decompiledir="$workdir/Minecraft/$minecraftversion/forge"
|
2019-01-01 11:15:55 +08:00
|
|
|
# replace for now
|
|
|
|
decompiledir="$workdir/Minecraft/$minecraftversion/spigot"
|
2016-03-31 08:50:23 +08:00
|
|
|
export importedmcdev=""
|
|
|
|
function import {
|
2018-05-25 02:41:50 +08:00
|
|
|
export importedmcdev="$importedmcdev $1"
|
|
|
|
file="${1}.java"
|
|
|
|
target="$workdir/Spigot/Spigot-Server/src/main/java/$nms/$file"
|
|
|
|
base="$decompiledir/$nms/$file"
|
2016-03-31 08:50:23 +08:00
|
|
|
|
2018-05-25 02:41:50 +08:00
|
|
|
if [[ ! -f "$target" ]]; then
|
|
|
|
export MODLOG="$MODLOG Imported $file from mc-dev\n";
|
2018-07-15 09:53:17 +08:00
|
|
|
#echo "Copying $base to $target"
|
|
|
|
cp "$base" "$target" || exit 1
|
2018-05-25 02:41:50 +08:00
|
|
|
else
|
|
|
|
echo "UN-NEEDED IMPORT: $file"
|
|
|
|
fi
|
2016-03-31 08:50:23 +08:00
|
|
|
}
|
|
|
|
|
2018-09-04 07:55:14 +08:00
|
|
|
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";
|
2019-02-11 05:53:53 +08:00
|
|
|
sed 's/\r$//' "$base" > "$target" || exit 1
|
2018-09-04 07:55:14 +08:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-03-31 08:50:23 +08:00
|
|
|
(
|
2018-05-25 02:41:50 +08:00
|
|
|
cd "$workdir/Spigot/Spigot-Server/"
|
|
|
|
lastlog=$($gitcmd log -1 --oneline)
|
|
|
|
if [[ "$lastlog" = *"mc-dev Imports"* ]]; then
|
|
|
|
$gitcmd reset --hard HEAD^
|
|
|
|
fi
|
2016-03-31 08:50:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-07-15 09:53:17 +08:00
|
|
|
|
|
|
|
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')
|
|
|
|
|
2018-09-04 02:57:29 +08:00
|
|
|
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')
|
2018-07-15 09:53:17 +08:00
|
|
|
function containsElement {
|
|
|
|
local e
|
|
|
|
for e in "${@:2}"; do
|
|
|
|
[[ "$e" == "$1" ]] && return 0;
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
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 "$decompiledir/$nms/$f.java" ]; then
|
|
|
|
echo "$(color 1 31) ERROR!!! Missing NMS$(color 1 34) $f $(colorend)";
|
|
|
|
else
|
|
|
|
import $f
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-09-04 13:50:14 +08:00
|
|
|
########################################################
|
|
|
|
########################################################
|
|
|
|
########################################################
|
|
|
|
# NMS IMPORTS
|
2018-07-22 05:24:18 +08:00
|
|
|
# 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.
|
2018-09-04 13:50:14 +08:00
|
|
|
# we do not need any lines added to this file for NMS
|
2018-07-22 05:24:18 +08:00
|
|
|
|
|
|
|
# import FileName
|
|
|
|
|
|
|
|
|
2019-05-27 14:14:14 +08:00
|
|
|
|
2018-09-04 13:50:14 +08:00
|
|
|
########################################################
|
|
|
|
########################################################
|
|
|
|
########################################################
|
|
|
|
# LIBRARY IMPORTS
|
|
|
|
# These must always be mapped manually, no automatic stuff
|
|
|
|
#
|
|
|
|
# # group # lib # prefix # many files
|
|
|
|
|
|
|
|
# dont forget \ at end of each line but last
|
2018-10-24 09:14:03 +08:00
|
|
|
importLibrary com.mojang authlib com/mojang/authlib yggdrasil/YggdrasilGameProfileRepository.java
|
2018-07-15 09:53:17 +08:00
|
|
|
|
2018-09-04 13:50:14 +08:00
|
|
|
########################################################
|
|
|
|
########################################################
|
|
|
|
########################################################
|
2018-07-15 09:53:17 +08:00
|
|
|
set -e
|
2016-04-03 15:23:19 +08:00
|
|
|
cd "$workdir/Spigot/Spigot-Server/"
|
2016-05-13 10:11:11 +08:00
|
|
|
rm -rf nms-patches applyPatches.sh makePatches.sh >/dev/null 2>&1
|
2018-05-25 02:41:50 +08:00
|
|
|
$gitcmd add . -A >/dev/null 2>&1
|
|
|
|
echo -e "mc-dev Imports\n\n$MODLOG" | $gitcmd commit . -F -
|
2016-03-31 08:50:23 +08:00
|
|
|
)
|