Merge pull request #2 from jiriks74/add_fabric_support
Add initial support for Fabric
This commit is contained in:
commit
cd9c5910b7
@ -5,9 +5,10 @@ function get_existing_server {
|
||||
if ls paper-*.jar 1> /dev/null 2>&1; then
|
||||
existing_server_type="paper"
|
||||
get_existing_paper
|
||||
elif ls fabric-server-mc.*.jar 1> /dev/null 2>&1; then
|
||||
existing_server_type="fabric"
|
||||
get_existing_fabric
|
||||
# TODO: Add support for other server types
|
||||
# elif ls fabric-*.jar 1> /dev/null 2>&1; then
|
||||
# existing_server_type="fabric"
|
||||
# elif ls spigot-*.jar 1> /dev/null 2>&1; then
|
||||
# existing_server_type="spigot"
|
||||
# elif ls craftbukkit-*.jar 1> /dev/null 2>&1; then
|
||||
@ -30,6 +31,30 @@ function get_existing_server {
|
||||
fi
|
||||
}
|
||||
|
||||
# Get existing version and build of fabric
|
||||
function get_existing_fabric {
|
||||
# Get the current server file name
|
||||
server_file=$(basename ./fabric-server-mc.*.jar)
|
||||
|
||||
# Assign the file name to a variable
|
||||
FILE=$server_file
|
||||
|
||||
# Remove the .jar extension
|
||||
FILE=${FILE%.jar}
|
||||
|
||||
# Split by - and get the third field (mc.x.x.x)
|
||||
current_version=$(echo $FILE | cut -d. -f2,3,4 | cut -d- -f1)
|
||||
|
||||
# Split by - and get the fourth field (launcher.x.x.x)
|
||||
current_build=$(echo $FILE | cut -d- -f4 | cut -d. -f2,3,4)
|
||||
|
||||
echo "Current server file: $server_file"
|
||||
echo " - Version $current_version"
|
||||
echo " - Build $current_build"
|
||||
echo
|
||||
echo
|
||||
}
|
||||
|
||||
# Get existing version and build of paper
|
||||
function get_existing_paper {
|
||||
# Get the current server file name
|
||||
|
117
.msman/fabric.sh
Normal file
117
.msman/fabric.sh
Normal file
@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
# API URL
|
||||
api_url="https://meta.fabricmc.net/v2/versions/"
|
||||
|
||||
# Example server's jar file name:
|
||||
# fabric-server-mc.1.19.3-loader.0.14.14-launcher.0.11.1.jar
|
||||
|
||||
function check_version_valid {
|
||||
if [[ $(curl -s "$(echo $api_url)/loader/$(echo $version)") == "[]" ]]; then
|
||||
>&2 echo "Error: Invalid version selected: $version"
|
||||
exit 2
|
||||
else
|
||||
# Check if selected build exists
|
||||
if [ ! -z "$build" ]; then
|
||||
if [[ $(curl -s "$(echo $api_url)/loader/$(echo $version)/$(echo $build)") == "\"no loader version found for $(echo $version)\"" ]]; then
|
||||
>&2 echo "Error: Invalid build selected: $build"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function download_server {
|
||||
# Download the server
|
||||
echo "Downloading Fabric server..."
|
||||
echo " - Version $version"
|
||||
echo " - Build $download_build"
|
||||
echo " - Installer $latest_installer"
|
||||
curl "$(echo $api_url)/loader/$(echo $version)/$(echo $download_build)/$(echo $latest_installer)/server/jar" -o "./fabric-server-mc.$(echo $version)-loader.$(echo $download_build)-launcher.$(echo $latest_installer).jar"
|
||||
echo "Download complete."
|
||||
}
|
||||
|
||||
function check_updates {
|
||||
if [[ $server_file == false ]]; then
|
||||
download_build=$latest_build
|
||||
update_version=true
|
||||
update_build=true
|
||||
else
|
||||
echo Checking for updates...
|
||||
fi
|
||||
|
||||
# Check if $build is empty
|
||||
if [[ -z $build ]]; then
|
||||
# Check if the current version is the same as the one selected
|
||||
if [[ $current_version == $version ]]; then
|
||||
# Check if the current build is the same as the one selected
|
||||
if [[ $current_build == $latest_build ]]; then
|
||||
echo "Server is up to date."
|
||||
else
|
||||
echo "Server is not up to date."
|
||||
download_build=$latest_build
|
||||
update_build=true
|
||||
fi
|
||||
else
|
||||
# Check if $server_file is false
|
||||
ask_version_differs
|
||||
echo "Server is not up to date."
|
||||
download_build=$latest_build
|
||||
update_version=true
|
||||
fi
|
||||
else
|
||||
# Check if the current version is the same as the one selected
|
||||
if [[ $current_version == $version ]]; then
|
||||
# Check if the current build is the same as the one selected
|
||||
if [[ $current_build == $build ]]; then
|
||||
echo "Server is up to date."
|
||||
else
|
||||
echo "Server is not up to date."
|
||||
download_build=$build
|
||||
update_build=true
|
||||
fi
|
||||
else
|
||||
# Check if $server_file is false
|
||||
ask_version_differs
|
||||
echo "Server is not up to date."
|
||||
download_build=$build
|
||||
update_version=true
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Get the latest build number and installer version
|
||||
function get_latest_build {
|
||||
# Get the latest build number
|
||||
latest_build=$(curl -s "$(echo $api_url)/loader/$version" | jq -r '.[0].loader.version')
|
||||
latest_installer=$(curl -s "$(echo $api_url)/installer/" | jq -r '.[0].version')
|
||||
}
|
||||
|
||||
# Check if the server is up to date and update if it isn't
|
||||
function check_and_update {
|
||||
if ! [[ $server_file == false ]]; then
|
||||
echo Checking for updates...
|
||||
fi
|
||||
|
||||
# Get the latest build number
|
||||
get_latest_build
|
||||
|
||||
# Check if the current version is up to date
|
||||
check_updates
|
||||
|
||||
# Check if $build_update is true or $version_update is true
|
||||
if [[ $update_build == true ]] || [[ $update_version == true ]]; then
|
||||
if [[ $server_file != false ]]; then
|
||||
old_server_file=$server_file
|
||||
server_file="fabric-server-mc.$version-loader.$download_build-launcher.$latest_installer.jar"
|
||||
download_server
|
||||
# Delete the old server file
|
||||
delete_old_server
|
||||
else
|
||||
server_file="fabric-server-mc.$version-loader.$download_build-launcher.$latest_installer.jar"
|
||||
download_server
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
echo
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
EXTRA_SCRIPTS_VERSION="v1.1.8"
|
||||
EXTRA_SCRIPTS_VERSION="v2.0.0"
|
||||
|
@ -14,7 +14,9 @@
|
||||
# I am not responsible for any loss of data #
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
|
||||
|
||||
# Only paper is currently supported
|
||||
# Supported server types:
|
||||
# - paper
|
||||
# - fabric
|
||||
server_type="paper"
|
||||
version="1.19.3"
|
||||
# Leave blank to use the latest build (auto updates on every run)
|
||||
@ -38,7 +40,7 @@ mem="6000M"
|
||||
|
||||
# Flags for the server itself
|
||||
# Usefull fot setting rcon password, server port, etc.
|
||||
mc_launchoptions="-nogui"
|
||||
mc_launchoptions="nogui"
|
||||
|
||||
# If you want to get rid of script updates notifications, set the below to false
|
||||
check_for_script_updates=true
|
||||
|
10
msman.sh
10
msman.sh
@ -8,7 +8,7 @@ set -e
|
||||
# and acknowledge the original script and author. #
|
||||
#############################################################################################################
|
||||
|
||||
CURRENT_SCRIPT_VERSION="v1.1.8"
|
||||
CURRENT_SCRIPT_VERSION="v2.0.0"
|
||||
|
||||
# --------------------------------------------------
|
||||
# You shouldn't need to change anything in this file
|
||||
@ -199,7 +199,7 @@ function launch_server {
|
||||
echo "Starting the server..."
|
||||
echo
|
||||
echo
|
||||
java $java_launchoptions -jar "$(basename ./paper-*.jar)" $mc_launchoptions
|
||||
java $java_launchoptions -jar $server_file $mc_launchoptions
|
||||
}
|
||||
|
||||
# Helper scripts update
|
||||
@ -378,7 +378,7 @@ function load_config {
|
||||
# Delete old server file with name $old_server_file
|
||||
function delete_old_server {
|
||||
# Delete the old server file
|
||||
echo "Deleting old server file $server_file..."
|
||||
echo "Deleting old server file '$server_file...'"
|
||||
rm "$old_server_file"
|
||||
echo "Old server file deleted."
|
||||
}
|
||||
@ -393,12 +393,12 @@ function load_script {
|
||||
# Load the correct script
|
||||
if [[ $server_type == "paper" ]]; then
|
||||
source "./.msman/paper.sh"
|
||||
elif [[ $server_type == "fabric" ]]; then
|
||||
source "./.msman/fabric.sh"
|
||||
# elif [[ $server_type == "vanilla" ]]; then
|
||||
# source "$cwd/msman/vanilla.sh"
|
||||
# elif [[ $server_type == "forge" ]]; then
|
||||
# source "$cwd/msman/forge.sh"
|
||||
# elif [[ $server_type == "fabric" ]]; then
|
||||
# source "$cwd/msman/fabric.sh"
|
||||
else
|
||||
>&2 echo "Unknown server type."
|
||||
echo "Exiting..."
|
||||
|
Loading…
x
Reference in New Issue
Block a user