-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-plugins
executable file
·133 lines (112 loc) · 4.23 KB
/
get-plugins
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
124
125
126
127
128
129
130
131
132
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Define color codes
# RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RESET='\033[0m'
function log() {
echo -e "[init] $*"
}
declare -A plugin_names=(
[60623]="sleep-most"
[19286]="minepacks"
[104616]="healthbar-reloaded"
[109679]="bolt"
[84134]="better-revive"
[34315]="Vault"
[6245]="PlaceholderAPI"
)
declare -A plugin_urls=(
["LuckPerms"]="https://download.luckperms.net/1534/bukkit/loader/LuckPerms-Bukkit-5.4.121.jar"
["ProtocolLib"]="https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar"
["FastLogin"]="https://ci.codemc.io/job/Games647/job/FastLogin/lastSuccessfulBuild/artifact/bukkit/target/FastLoginBukkit.jar"
["AuthMe"]="https://ci.codemc.io/job/AuthMe/job/AuthMeReloaded/lastSuccessfulBuild/artifact/target/AuthMe-5.6.0-SNAPSHOT.jar"
["Graves"]="https://gitlab.com/ranull/minecraft/graves/uploads/2dcf3200faf0f76ab098269225436fe0/Graves-4.9.1.2.jar"
["nbt-api"]="https://cdn.modrinth.com/data/nfGCP9fk/versions/a7LQG0Ls/item-nbt-api-plugin-2.12.3.jar"
["SkinsRestorer"]="https://github.com/SkinsRestorer/SkinsRestorer/releases/latest/download/SkinsRestorer.jar"
)
containsJars() {
file=${1?}
pat='\.jar$'
while read -r line; do
if [[ $line =~ $pat ]]; then
return 0
fi
done <<< "$(unzip -l "$file")"
return 1
}
data_dir="$PWD/data/plugins"
getResourceFromSpiget() {
resource=${1?}
log "Downloading resource ${plugin_names[$resource]}.jar ..."
mkdir -p "$PWD/tmp"
tmpfile="$PWD/tmp/${resource}.zip"
url="https://api.spiget.org/v2/resources/${resource}/download"
# shellcheck disable=SC2154
if ! curl -o "${tmpfile}" -fsSL -H "User-Agent: itzg/minecraft-server" "${extraCurlArgs[@]}" "${url}"; then
log "ERROR failed to download resource '${resource}' from ${url}"
exit 2
fi
mkdir -p "$PWD/data/plugins"
if containsJars "${tmpfile}"; then
log "Extracting contents of resource ${resource} into plugins"
unzip -o -q -d "$data_dir" "${tmpfile}"
rm "${tmpfile}"
else
log "Moving resource ${plugin_names[$resource]}.jar into plugins"
mv "${tmpfile}" "$data_dir/${resource}.jar"
fi
if [[ ${plugin_names[$resource]+isset} ]]; then
new_filename="${plugin_names[$resource]}.jar"
mv "$data_dir"/"${resource}.jar" "$data_dir"/"$new_filename"
log "${GREEN}Downloaded and renamed plugin: $resource -> $new_filename${RESET}"
else
log "${YELLOW}Warning: No name mapping found for resource ID: $resource. Downloaded as ${resource}.jar${RESET}"
fi
}
log "Getting plugins via Spiget"
for resource_id in "${!plugin_names[@]}"
do
resource="${resource_id}"
getResourceFromSpiget "${resource}"
done
rm -r "$PWD/tmp"
if wget -q -P "$data_dir" "$url"; then
log "${GREEN}$plugin downloaded${RESET}"
else
log "ERROR: Failed to download $plugin from $url"
exit 1
fi
done
log "${YELLOW}Downloading GeyserMC${RESET}"
if wget -q https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot -O "$data_dir/Geyser-Spigot.jar"; then
log "${GREEN}GeyserMC downloaded${RESET}"
else
log "ERROR: Failed to download GeyserMC"
exit 1
fi
log "${YELLOW}Downloading Floodgate${RESET}"
if wget -q https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot -O "$data_dir/Floodgate-Spigot.jar"; then
log "${GREEN}Floodgate downloaded${RESET}"
else
log "ERROR: Failed to download Floodgate"
exit 1
fi
log "${YELLOW}Downloading EssentialsX${RESET}"
essentials_url=$(curl -s https://api.github.com/repos/EssentialsX/Essentials/releases/latest | jq -r '.assets[] | select(.name | contains ("EssentialsX-")) | .browser_download_url')
if wget -q -P "$data_dir" "$essentials_url"; then
log "${GREEN}EssentialsX Downloaded${RESET}"
else
log "ERROR: Failed to download EssentialsX"
exit 1
fi
log "${YELLOW}Downloading EssentialsX Chat${RESET}"
essentials_chat_url=$(curl -s https://api.github.com/repos/EssentialsX/Essentials/releases/latest | jq -r '.assets[] | select(.name | contains ("EssentialsXChat")) | .browser_download_url')
if wget -q -P "$data_dir" "$essentials_chat_url"; then
log "${GREEN}EssentialsX Chat Downloaded${RESET}"
else
log "ERROR: Failed to download EssentialsX Chat"
exit 1
fi