Cleanup and restructure the project
This commit is contained in:
parent
cd3d8fb27e
commit
8b66d99e73
21 changed files with 193 additions and 115 deletions
70
scripts/applyPatches.sh
Executable file
70
scripts/applyPatches.sh
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PS1="$"
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
echo "Rebuilding Forked projects.... "
|
||||
|
||||
function applyPatch {
|
||||
what=$1
|
||||
what_name=$(basename "$what")
|
||||
target=$2
|
||||
branch=$3
|
||||
|
||||
cd "$basedir/$what"
|
||||
git fetch
|
||||
git branch -f upstream "$branch" >/dev/null
|
||||
|
||||
cd "$basedir"
|
||||
if [ ! -d "$basedir/$target" ]; then
|
||||
git clone "$what" "$target"
|
||||
fi
|
||||
cd "$basedir/$target"
|
||||
echo "Resetting $target to $what_name..."
|
||||
git remote rm upstream > /dev/null 2>&1
|
||||
git remote add upstream "$basedir/$what" >/dev/null 2>&1
|
||||
git checkout master 2>/dev/null || git checkout -b master
|
||||
git fetch upstream >/dev/null 2>&1
|
||||
git reset --hard upstream/upstream
|
||||
echo " Applying patches to $target..."
|
||||
git am --abort >/dev/null 2>&1
|
||||
git am --3way --ignore-whitespace "$basedir/${what_name}-Patches/"*.patch
|
||||
if [ "$?" != "0" ]; then
|
||||
echo " Something did not apply cleanly to $target."
|
||||
echo " Please review above details and finish the apply then"
|
||||
echo " save the changes with rebuildPatches.sh"
|
||||
exit 1
|
||||
else
|
||||
echo " Patches applied cleanly to $target"
|
||||
fi
|
||||
}
|
||||
|
||||
# Move into spigot dir
|
||||
cd "$workdir/Spigot"
|
||||
basedir=$(pwd)
|
||||
# Apply Spigot
|
||||
(
|
||||
applyPatch ../Bukkit Spigot-API HEAD &&
|
||||
applyPatch ../CraftBukkit Spigot-Server patched
|
||||
) || (
|
||||
echo "Failed to apply Spigot Patches"
|
||||
exit 1
|
||||
) || exit 1
|
||||
# Move out of Spigot
|
||||
basedir="$1"
|
||||
cd "$basedir"
|
||||
|
||||
echo "Importing MC Dev"
|
||||
|
||||
./scripts/importmcdev.sh "$basedir"
|
||||
|
||||
# Apply paper
|
||||
cd "$basedir"
|
||||
(
|
||||
applyPatch "work/Spigot/Spigot-API" Paper-API HEAD &&
|
||||
applyPatch "work/Spigot/Spigot-Server" Paper-Server HEAD
|
||||
) || (
|
||||
echo "Failed to apply Paper Patches"
|
||||
exit 1
|
||||
) || exit 1
|
||||
|
11
scripts/build.sh
Executable file
11
scripts/build.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
basedir="$1"
|
||||
|
||||
(git submodule update --init && ./scripts/remap.sh "$basedir" && ./scripts/decompile.sh "$basedir" && ./scripts/init.sh "$basedir" && ./scripts/applyPatches.sh "$basedir") || (
|
||||
echo "Failed to build Paper"
|
||||
exit 1
|
||||
) || exit 1
|
||||
if [ "$2" == "--jar" ]; then
|
||||
(mvn clean install && ./scripts/paperclip.sh "$basedir") || exit 1
|
||||
fi
|
30
scripts/decompile.sh
Executable file
30
scripts/decompile.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PS1="$"
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
decompiledir="$workdir/$minecraftversion"
|
||||
classdir="$decompiledir/classes"
|
||||
|
||||
echo "Extracting NMS classes..."
|
||||
if [ ! -d "$classdir" ]; then
|
||||
mkdir -p "$classdir"
|
||||
cd "$classdir"
|
||||
jar xf "$decompiledir/$minecraftversion-mapped.jar" net/minecraft/server
|
||||
if [ "$?" != "0" ]; then
|
||||
cd "$basedir"
|
||||
echo "Failed to extract NMS classes."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Decompiling classes..."
|
||||
if [ ! -d "$decompiledir/net/minecraft/server" ]; then
|
||||
cd "$basedir"
|
||||
java -jar "$workdir/BuildData/bin/fernflower.jar" -dgs=1 -hdc=0 -asc=1 -udv=0 "$classdir" "$decompiledir"
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Failed to decompile classes."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
70
scripts/envSetup.sh
Normal file
70
scripts/envSetup.sh
Normal file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Set root project directory
|
||||
CWD=$(pwd)
|
||||
|
||||
rbp() {
|
||||
NEW_CWD=$(pwd)
|
||||
cd "$CWD"
|
||||
scripts/rebuildPatches.sh "$CWD"
|
||||
cd "$NEW_CWD"
|
||||
}
|
||||
|
||||
rebuildPatches() {
|
||||
rbp
|
||||
}
|
||||
|
||||
lunch() {
|
||||
NEW_CWD=$(pwd)
|
||||
cd "$CWD"
|
||||
|
||||
if [[ "$1" = "jar" ]] || [[ "$1" = "--jar" ]] ; then
|
||||
ARG="--jar"
|
||||
fi
|
||||
|
||||
scripts/build.sh "$CWD" "$ARG"
|
||||
ARG=""
|
||||
|
||||
cd "$NEW_CWD"
|
||||
}
|
||||
|
||||
root() {
|
||||
cd "$CWD"
|
||||
}
|
||||
|
||||
LAST_EDIT=""
|
||||
|
||||
edit() {
|
||||
if [[ "$1" = "server" ]] ; then
|
||||
cd "$CWD/Paper-Server"
|
||||
LAST_EDIT=$(pwd)
|
||||
|
||||
stash
|
||||
git rebase -i upstream/upstream
|
||||
unstash
|
||||
elif [[ "$1" = "api" ]] ; then
|
||||
cd "$CWD/Paper-API"
|
||||
LAST_EDIT=$(pwd)
|
||||
|
||||
stash
|
||||
git rebase -i upstream/upstream
|
||||
unstash
|
||||
elif [[ "$1" = "continue" ]] ; then
|
||||
cd "$LAST_EDIT"
|
||||
git add .
|
||||
git commit --amend
|
||||
git rebase --continue
|
||||
else
|
||||
echo "You must edit either the api or server."
|
||||
fi
|
||||
}
|
||||
|
||||
stash() {
|
||||
STASHED=$(git stash)
|
||||
}
|
||||
|
||||
unstash() {
|
||||
if [[ "$STASHED" != "No local changes to save" ]] ; then
|
||||
git stash pop
|
||||
fi
|
||||
}
|
66
scripts/importmcdev.sh
Executable file
66
scripts/importmcdev.sh
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
nms="net/minecraft/server"
|
||||
export MODLOG=""
|
||||
PS1="$"
|
||||
basedir="$1"
|
||||
|
||||
workdir="$basedir/work"
|
||||
minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
decompiledir="$workdir/$minecraftversion"
|
||||
|
||||
export importedmcdev=""
|
||||
function import {
|
||||
export importedmcdev="$importedmcdev $1"
|
||||
file="${1}.java"
|
||||
target="$workdir/Spigot/Spigot-Server/src/main/java/$nms/$file"
|
||||
base="$decompiledir/$nms/$file"
|
||||
|
||||
if [[ ! -f "$target" ]]; then
|
||||
export MODLOG="$MODLOG Imported $file from mc-dev\n";
|
||||
echo "Copying $base to $target"
|
||||
cp "$base" "$target"
|
||||
fi
|
||||
}
|
||||
|
||||
(
|
||||
cd "$workdir/Spigot/Spigot-Server/"
|
||||
lastlog=$(git log -1 --oneline)
|
||||
if [[ "$lastlog" = *"mc-dev Imports"* ]]; then
|
||||
git reset --hard HEAD^
|
||||
fi
|
||||
)
|
||||
|
||||
import BaseBlockPosition
|
||||
import BiomeBase
|
||||
import BiomeMesa
|
||||
import BlockChest
|
||||
import BlockFalling
|
||||
import BlockFluids
|
||||
import BlockPosition
|
||||
import BlockStateList
|
||||
import ChunkProviderFlat
|
||||
import ChunkProviderGenerate
|
||||
import ChunkProviderHell
|
||||
import CommandAbstract
|
||||
import CommandScoreboard
|
||||
import CommandWhitelist
|
||||
import DataConverterMaterialId
|
||||
import EULA
|
||||
import EntitySquid
|
||||
import FileIOThread
|
||||
import ItemBlock
|
||||
import PacketPlayInResourcePackStatus
|
||||
import PacketPlayOutPlayerListHeaderFooter
|
||||
import PacketPlayOutTitle
|
||||
import PacketPlayOutUpdateTime
|
||||
import PathfinderAbstract
|
||||
import PathfinderGoalFloat
|
||||
import PersistentVillage
|
||||
import TileEntityEnderChest
|
||||
|
||||
(
|
||||
cd "$workdir/Spigot/Spigot-Server/"
|
||||
git add src -A
|
||||
echo -e "mc-dev Imports\n\n$MODLOG" | git commit src -F -
|
||||
)
|
35
scripts/init.sh
Executable file
35
scripts/init.sh
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PS1="$"
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
decompiledir="$workdir/$minecraftversion"
|
||||
nms="$decompiledir/net/minecraft/server"
|
||||
cb="src/main/java/net/minecraft/server"
|
||||
|
||||
patch=$(which patch 2>/dev/null)
|
||||
if [ "x$patch" == "x" ]; then
|
||||
patch="$basedir/hctap.exe"
|
||||
fi
|
||||
|
||||
echo "Applying CraftBukkit patches to NMS..."
|
||||
cd "$workdir/CraftBukkit"
|
||||
git checkout -B patched HEAD >/dev/null 2>&1
|
||||
rm -rf "$cb"
|
||||
mkdir -p "$cb"
|
||||
for file in $(ls nms-patches)
|
||||
do
|
||||
patchFile="nms-patches/$file"
|
||||
file="$(echo "$file" | cut -d. -f1).java"
|
||||
|
||||
echo "Patching $file < $patchFile"
|
||||
sed -i 's/\r//' "$nms/$file" > /dev/null
|
||||
|
||||
cp "$nms/$file" "$cb/$file"
|
||||
"$patch" -s -d src/main/java/ "net/minecraft/server/$file" < "$patchFile"
|
||||
done
|
||||
|
||||
git add src >/dev/null 2>&1 || exit 1
|
||||
git commit -m "CraftBukkit $ $(date)" >/dev/null 2>&1 || exit 1
|
||||
git checkout -f HEAD^ >/dev/null 2>&1 || exit 1
|
25
scripts/makemcdevsrc.sh
Executable file
25
scripts/makemcdevsrc.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PS1="$"
|
||||
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
minecraftversion=$(cat "$basedir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
decompiledir="$workdir/$minecraftversion"
|
||||
nms="$decompiledir/net/minecraft/server"
|
||||
papernms="Paper-Server/src/main/java/net/minecraft/server"
|
||||
mcdevsrc="${decompiledir}/src/net/minecraft/server"
|
||||
rm -rf "${mcdevsrc}"
|
||||
mkdir -p "${mcdevsrc}"
|
||||
cp ${nms}/*.java "${mcdevsrc}/"
|
||||
|
||||
for file in "${nms}/"*
|
||||
do
|
||||
file=${file##*/}
|
||||
# test if in Paper folder - already imported
|
||||
if [ -f "${papernms}/${file}" ]; then
|
||||
# remove from mcdevsrc folder
|
||||
rm -f "${mcdevsrc}/${file}"
|
||||
fi
|
||||
done
|
||||
echo "Built $decompiledir/src to be included in your project for src access";
|
17
scripts/paperclip.sh
Executable file
17
scripts/paperclip.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
paperjar="../../Paper-Server/target/paper-$mcver.jar"
|
||||
vanillajar="../$mcver/$mcver.jar"
|
||||
|
||||
cd "$workdir/Paperclip"
|
||||
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar"
|
||||
cd ..
|
||||
cp "$workdir/Paperclip/target/paperclip-${mcver}.jar" "$basedir/paperclip.jar"
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Build success!"
|
||||
echo "Copied final jar to $basedir/paperclip.jar"
|
47
scripts/rebuildPatches.sh
Executable file
47
scripts/rebuildPatches.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PS1="$"
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
echo "Rebuilding patch files from current fork state..."
|
||||
git config core.safecrlf false
|
||||
|
||||
function cleanupPatches {
|
||||
cd "$1"
|
||||
for patch in *.patch; do
|
||||
echo "$patch"
|
||||
gitver=$(tail -n 2 "$patch" | grep -ve "^$" | tail -n 1)
|
||||
diffs=$(git diff --staged "$patch" | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index)")
|
||||
|
||||
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
|
||||
if [ "x$testver" != "x" ]; then
|
||||
diffs=$(echo "$diffs" | sed 'N;$!P;$!D;$d')
|
||||
fi
|
||||
|
||||
if [ "x$diffs" == "x" ] ; then
|
||||
git reset HEAD "$patch" >/dev/null
|
||||
git checkout -- "$patch" >/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function savePatches {
|
||||
what=$1
|
||||
what_name=$(basename "$what")
|
||||
target=$2
|
||||
echo "Formatting patches for $what..."
|
||||
|
||||
cd "$basedir/${what_name}-Patches/"
|
||||
rm -rf *.patch
|
||||
|
||||
cd "$basedir/$target"
|
||||
|
||||
git format-patch --no-stat -N -o "$basedir/${what_name}-Patches/" upstream/upstream >/dev/null
|
||||
cd "$basedir"
|
||||
git add -A "$basedir/${what_name}-Patches"
|
||||
cleanupPatches "$basedir/${what_name}-Patches"
|
||||
echo " Patches saved for $what to $what_name-Patches/"
|
||||
}
|
||||
|
||||
savePatches "$workdir/Spigot/Spigot-API" "Paper-API"
|
||||
savePatches "$workdir/Spigot/Spigot-Server" "Paper-Server"
|
70
scripts/remap.sh
Executable file
70
scripts/remap.sh
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PS1="$"
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
minecraftversion=$(cat ${workdir}/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
|
||||
minecrafthash=$(cat ${workdir}/BuildData/info.json | grep minecraftHash | cut -d '"' -f 4)
|
||||
accesstransforms="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep accessTransforms | cut -d '"' -f 4)
|
||||
classmappings="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep classMappings | cut -d '"' -f 4)
|
||||
membermappings="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep memberMappings | cut -d '"' -f 4)
|
||||
packagemappings="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep packageMappings | cut -d '"' -f 4)
|
||||
jarpath="$workdir/$minecraftversion/$minecraftversion"
|
||||
|
||||
echo "Downloading unmapped vanilla jar..."
|
||||
if [ ! -f "$jarpath.jar" ]; then
|
||||
mkdir -p "$workdir/$minecraftversion"
|
||||
curl -s -o "$jarpath.jar" "https://s3.amazonaws.com/Minecraft.Download/versions/$minecraftversion/minecraft_server.$minecraftversion.jar"
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Failed to download the vanilla server jar. Check connectivity or try again later."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# OS X doesn't have md5sum, just md5 -r
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
shopt -s expand_aliases
|
||||
alias md5sum='md5 -r'
|
||||
echo "Using an alias for md5sum on OS X"
|
||||
fi
|
||||
|
||||
checksum=$(md5sum "$jarpath.jar" | cut -d ' ' -f 1)
|
||||
if [ "$checksum" != "$minecrafthash" ]; then
|
||||
echo "The MD5 checksum of the downloaded server jar does not match the BuildData hash."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Applying class mappings..."
|
||||
if [ ! -f "$jarpath-cl.jar" ]; then
|
||||
java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map -i "$jarpath.jar" -m "$classmappings" -o "$jarpath-cl.jar" 1>/dev/null
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Failed to apply class mappings."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Applying member mappings..."
|
||||
if [ ! -f "$jarpath-m.jar" ]; then
|
||||
java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map -i "$jarpath-cl.jar" -m "$membermappings" -o "$jarpath-m.jar" 1>/dev/null
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Failed to apply member mappings."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Creating remapped jar..."
|
||||
if [ ! -f "$jarpath-mapped.jar" ]; then
|
||||
java -jar "$workdir/BuildData/bin/SpecialSource.jar" --kill-lvt -i "$jarpath-m.jar" --access-transformer "$accesstransforms" -m "$packagemappings" -o "$jarpath-mapped.jar" 1>/dev/null
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Failed to create remapped jar."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Installing remapped jar..."
|
||||
cd "$workdir/CraftBukkit" # Need to be in a directory with a valid POM at the time of install.
|
||||
mvn install:install-file -q -Dfile="$jarpath-mapped.jar" -Dpackaging=jar -DgroupId=org.spigotmc -DartifactId=minecraft-server -Dversion="$minecraftversion-SNAPSHOT"
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Failed to install remapped jar."
|
||||
exit 1
|
||||
fi
|
16
scripts/upstreamMerge.sh
Executable file
16
scripts/upstreamMerge.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PS1="$"
|
||||
basedir="$1"
|
||||
workdir="$basedir/work"
|
||||
|
||||
function update {
|
||||
cd "$workdir/$1"
|
||||
git fetch && git reset --hard origin/master
|
||||
cd ../
|
||||
git add $1
|
||||
}
|
||||
|
||||
update Bukkit
|
||||
update CraftBukkit
|
||||
update Spigot
|
Loading…
Add table
Add a link
Reference in a new issue