-
Notifications
You must be signed in to change notification settings - Fork 6
/
loom
executable file
·123 lines (102 loc) · 3.08 KB
/
loom
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
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
# resolve shell-specifics
case "$(echo "$SHELL" | sed -E 's|/usr(/local)?||g')" in
"/bin/zsh")
RCPATH="$HOME/.zshrc"
SOURCE="${BASH_SOURCE[0]:-${(%):-%N}}"
;;
*)
RCPATH="$HOME/.bashrc"
if [[ -f "$HOME/.bash_aliases" ]]; then
RCPATH="$HOME/.bash_aliases"
fi
SOURCE="${BASH_SOURCE[0]}"
;;
esac
# get base dir regardless of execution location
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE")
failed=0
########
# Loom #
########
mcVersion=$(cat ".loomversion")
showHelp () {
echo "This tool provides a variety of commands to manage a Loom development environment."
echo ""
echo "Usage: loom [command]"
echo ""
echo "Commands:"
echo ""
echo " c, clean | Clean the repository."
echo " s, setup | Setup the repository. (Downloads, maps, decompiles and patches the MC Server)"
echo " p, patch | Apply all Loom patches. (Required a set up repository)"
echo " rb, rebuild | Create/update patches base on your current project source."
echo " jar | Create a distributable server jar for Loom."
# echo " switchVersion <version> | Switch the Minecraft version you are targeting"
echo ""
echo "Selected version: $mcVersion"
echo ""
}
cleanRepository() {
printf "\r%-60s" "Removing: .cache"
rm -rf ./.cache
printf "\r%-60s" "Removing: ./server/src/main/java/net"
rm -rf ./server/src/main/java/net
printf "\r%-60s" "Removing: Paperclip submodule"
git submodule deinit --all -f &> /dev/null
printf "\r%-60s" "Cleaned repository!"
}
setupRepository() {
(
git submodule update --init --recursive || exit 1
tools/scripts/downloadMinecraftServer.sh || exit 1
tools/scripts/decompile.sh || exit 1
tools/scripts/applyPatches.sh || exit 1
echo ""
echo "Set up!"
echo ""
) || failed=1
}
applyPatches() {
(
tools/scripts/applyPatches.sh || exit 1
echo ""
echo "Patched!"
echo ""
) || failed=1
}
rebuildPatches() {
(
tools/scripts/rebuildPatches.sh || exit 1
echo ""
echo "Build Patched!"
echo ""
) || failed=1
}
buildJar() {
(
mvn package || exit 1
tools/scripts/buildJar.sh || exit 1
echo ""
echo "Build Jar! (loom-$mcVersion.jar)"
echo ""
) || failed=1
}
case "$1" in
"c" | "clean") cleanRepository ;;
"s" | "setup") setupRepository ;;
"p" | "patch") applyPatches ;;
"rb" | "rebuild") rebuildPatches ;;
"jar") buildJar ;;
*) showHelp ;;
esac
unset RCPATH
unset SOURCE
unset basedir
exit $failed