Add via version management
This commit is contained in:
parent
9b209b7d4f
commit
193045bd40
75
configure.sh
75
configure.sh
@ -4,15 +4,28 @@
|
||||
STANDALONE_PORT=25565
|
||||
# port of the server in proxy mode, aka the internal port
|
||||
PROXY_PORT=25566
|
||||
# installs ViaVersion on BungeeCord and standalone mode, removes it in Velocity mode
|
||||
MANAGE_VIA_VERSION=true
|
||||
# installs ViaBackwards on BungeeCord and standalone mode, removes it in Velocity mode
|
||||
MANAGE_VIA_BACKWARDS=$MANAGE_VIA_VERSION
|
||||
|
||||
# Prefix of the ViaVersion jar
|
||||
VIA_VERSION_NAME="ViaVersion"
|
||||
# Prefix of the ViaBackwards jar
|
||||
VIA_BACKWARDS_NAME="ViaBackwards"
|
||||
# Github repo of ViaVersion project
|
||||
VIA_VERSION_REPO="ViaVersion/ViaVersion"
|
||||
# Github repo of ViaBackwards project
|
||||
VIA_BACKWARDS_REPO="ViaVersion/ViaBackwards"
|
||||
|
||||
function main {
|
||||
|
||||
# parse arguments
|
||||
velocity=false
|
||||
bungeecord=false
|
||||
standalone=false
|
||||
fetch=false
|
||||
help=false
|
||||
local velocity=false
|
||||
local bungeecord=false
|
||||
local standalone=false
|
||||
local fetch=false
|
||||
local help=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
@ -78,21 +91,45 @@ function main {
|
||||
fi
|
||||
|
||||
# Do the actual configuration
|
||||
|
||||
# Velocity
|
||||
if $velocity; then
|
||||
enable_online_mode false
|
||||
set_port "$PROXY_PORT"
|
||||
enable_velocity true
|
||||
enable_bungeecord false
|
||||
if $MANAGE_VIA_VERSION; then
|
||||
remove_plugin "$VIA_VERSION_NAME"
|
||||
fi
|
||||
if $MANAGE_VIA_BACKWARDS; then
|
||||
remove_plugin "$VIA_BACKWARDS_NAME"
|
||||
fi
|
||||
|
||||
# BungeeCord
|
||||
elif $bungeecord; then
|
||||
enable_online_mode false
|
||||
set_port "$PROXY_PORT"
|
||||
enable_velocity false
|
||||
enable_bungeecord true
|
||||
if $MANAGE_VIA_VERSION; then
|
||||
update_plugin "$VIA_VERSION_NAME" "$VIA_VERSION_REPO"
|
||||
fi
|
||||
if $MANAGE_VIA_BACKWARDS; then
|
||||
update_plugin "$VIA_BACKWARDS_NAME" "$VIA_BACKWARDS_REPO"
|
||||
fi
|
||||
|
||||
# standalone
|
||||
elif $standalone; then
|
||||
enable_online_mode true
|
||||
set_port "$STANDALONE_PORT"
|
||||
enable_velocity false
|
||||
enable_bungeecord false
|
||||
if $MANAGE_VIA_VERSION; then
|
||||
update_plugin "$VIA_VERSION_NAME" "$VIA_VERSION_REPO"
|
||||
fi
|
||||
if $MANAGE_VIA_BACKWARDS; then
|
||||
update_plugin "$VIA_BACKWARDS_NAME" "$VIA_BACKWARDS_REPO"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -125,4 +162,32 @@ function enable_bungeecord {
|
||||
yq -iy ".settings.bungeecord = $1" spigot.yml
|
||||
}
|
||||
|
||||
# Removes a plugin
|
||||
#
|
||||
# Usage: remove_plugin <jar-prefix>
|
||||
function remove_plugin {
|
||||
local plugin_name=$1
|
||||
rm plugins/"$plugin_name"*.jar 2>/dev/null
|
||||
}
|
||||
|
||||
# Update the latest release of a plugin from github
|
||||
#
|
||||
# Usage: update_plugin <jar-prefix> <repo>
|
||||
function update_plugin {
|
||||
local plugin_name=$1
|
||||
local repo=$2
|
||||
remove_plugin $plugin_name
|
||||
download_jar_from_github $repo "plugins/"
|
||||
}
|
||||
|
||||
# Download the jar files from the latest release of a github repo
|
||||
#
|
||||
# Usage: download_jar_from_github <repo> <destination>
|
||||
function download_jar_from_github {
|
||||
local repo=$1
|
||||
local dst=$2
|
||||
local url=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | jq -r '.assets[] | select(.name | endswith(".jar")) | .browser_download_url')
|
||||
wget -qP "$dst" "$url"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user