-
Notifications
You must be signed in to change notification settings - Fork 0
/
yukkit
executable file
·112 lines (98 loc) · 2.17 KB
/
yukkit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
set -eux
paper_url=https://github.com/PaperMC/Paper.git
paper_ref=ver/1.12.2
paper_remote=origin
fetch() {
(
if [ ! -d modules/Paper ]; then
git clone $paper_url modules/Paper
else
cd modules/Paper \
&& git fetch $paper_remote $paper_ref
fi
) || (
echo 'Failed to fetch from upstream. (Paper)'
exit 1
)
}
x_patch_git() {
local dir=${1:?} \
&& mkdir -p "$dir" \
&& find "$dir" -mindepth 1 -maxdepth 1 -type f -iname '*.patch' -print0 | xargs -0 git am -3
}
x_patch_paper() {
(
x_patch_paper_cleanup
) && (
cd modules/Paper \
&& x_patch_git ../../patches/Paper \
&& ./paper patch
)
}
x_patch_paper_cleanup() {
(
cd modules/Paper \
&& git switch -f -C ver/1.12.2 $paper_remote/$paper_ref \
&& echo 'Cleanup success!'
)
}
patch() {
(
x_patch_paper
) || (
echo 'Failed to apply Yukkit patches.'
exit 1
)
}
x_save_git() {
(
local repo=${1:?} \
&& local ref=${2:?} \
&& local to=${3:?} \
&& cd "$repo" \
&& rm -rf "$to" \
&& mkdir -p "$to" \
&& git format-patch -o "$to" -pN --zero-commit "$ref"
)
}
save() {
(
x_save_git modules/Paper $paper_remote/$paper_ref ../../patches/Paper \
&& x_save_git modules/Yukkit-API upstream/upstream ../../patches/Yukkit-API \
&& x_save_git modules/Yukkit-Server upstream/upstream ../../patches/Yukkit-Server
) || (
echo 'Failed to save Yukkit patches.'
exit 1
)
}
build() {
./gradlew --console=plain shadowJar
}
clip() {
mvn -B \
-f modules/Paper/work/Paperclip/pom.xml \
-Dmcver=1.12.2 \
-Dpaperjar=../../../../Yukkit-Server/build/libs/Yukkit-Server-1.12.2-R0.1-SNAPSHOT-all.jar \
-Dvanillajar=../../Minecraft/1.12.2/1.12.2.jar \
clean package \
&& cp -v modules/Paper/work/Paperclip/assembly/target/paperclip-1.12.2.jar Yukkit.jar
}
jar() {
fetch
patch
build
clip
}
usage() {
echo -e "Usage >> \e[1;31m$0 [ fetch | patch | build | clip | jar | save ]\e[m"
}
case "${1-}" in
fetch | load | init ) fetch ;;
patch | apply ) patch ;;
build ) build ;;
clip ) clip ;;
jar ) jar ;;
save ) save ;;
*) usage ;;
esac