Quellcode durchsuchen

feat(newserver): add PaperMC Server and Waterfall (#3292)

* feature(newserver): add PaperMC Server and Waterfall

PaperMC is a Minecraft server fork of spigot (which is a fork of Bukkit) with some improvement and also an API to check when update is needed
It support version selection via the API

Co-authored-by: Daniel Gibbs <me@danielgibbs.co.uk>
Christian vor 5 Jahren
Ursprung
Commit
7640496726

+ 173 - 0
lgsm/config-default/config-lgsm/pmcserver/_default.cfg

@@ -0,0 +1,173 @@
+##################################
+######## Default Settings ########
+##################################
+# DO NOT EDIT, ANY CHANGES WILL BE OVERWRITTEN!
+# Copy settings from here and use them in either:
+# common.cfg - applies settings to every instance.
+# [instance].cfg - applies settings to a specific instance.
+
+#### Game Server Settings ####
+
+## Predefined Parameters | https://docs.linuxgsm.com/configuration/start-parameters
+javaram="1024" # -Xmx$1024M
+
+## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
+startparameters="nogui"
+
+## Release Settings | https://docs.linuxgsm.com/game-servers/minecraft#release-settings
+# Version (latest|1.16.5)
+mcversion="latest"
+
+#### LinuxGSM Settings ####
+
+## LinuxGSM Stats
+# Send useful stats to LinuxGSM developers.
+# https://docs.linuxgsm.com/configuration/linuxgsm-stats
+# (on|off)
+stats="off"
+
+## Notification Alerts
+# (on|off)
+
+# Display IP | https://docs.linuxgsm.com/alerts#display-ip
+displayip=""
+
+# More info | https://docs.linuxgsm.com/alerts#more-info
+postalert="off"
+
+# Discord Alerts | https://docs.linuxgsm.com/alerts/discord
+discordalert="off"
+discordwebhook="webhook"
+
+# Email Alerts | https://docs.linuxgsm.com/alerts/email
+emailalert="off"
+email="email@example.com"
+emailfrom=""
+
+# IFTTT Alerts | https://docs.linuxgsm.com/alerts/ifttt
+iftttalert="off"
+ifttttoken="accesstoken"
+iftttevent="linuxgsm_alert"
+
+# Mailgun Email Alerts | https://docs.linuxgsm.com/alerts/mailgun
+mailgunalert="off"
+mailgunapiregion="us"
+mailguntoken="accesstoken"
+mailgundomain="example.com"
+mailgunemailfrom="alert@example.com"
+mailgunemail="email@myemail.com"
+
+# Pushbullet Alerts | https://docs.linuxgsm.com/alerts/pushbullet
+pushbulletalert="off"
+pushbullettoken="accesstoken"
+channeltag=""
+
+# Pushover Alerts | https://docs.linuxgsm.com/alerts/pushover
+pushoveralert="off"
+pushovertoken="accesstoken"
+pushoveruserkey="userkey"
+
+# Rocket.Chat Alerts | https://docs.linuxgsm.com/alerts/rocket.chat
+rocketchatalert="off"
+rocketchatwebhook="webhook"
+rocketchattoken=""
+
+# Slack Alerts | https://docs.linuxgsm.com/alerts/slack
+slackalert="off"
+slackwebhook="webhook"
+
+# Telegram Alerts | https://docs.linuxgsm.com/alerts/telegram
+# You can add a custom cURL string eg proxy (useful in Russia) in "curlcustomstring".
+# For example "--socks5 ipaddr:port" for socks5 proxy see more in "curl --help".
+telegramapi="api.telegram.org"
+telegramalert="off"
+telegramtoken="accesstoken"
+telegramchatid=""
+curlcustomstring=""
+
+## Updating | https://docs.linuxgsm.com/commands/update
+updateonstart="off"
+
+## Backup | https://docs.linuxgsm.com/commands/backup
+maxbackups="4"
+maxbackupdays="30"
+stoponbackup="on"
+
+## Logging | https://docs.linuxgsm.com/features/logging
+consolelogging="on"
+logdays="7"
+
+## Monitor | https://docs.linuxgsm.com/commands/monitor
+# Query delay time
+querydelay="1"
+
+## ANSI Colors | https://docs.linuxgsm.com/features/ansi-colors
+ansi="on"
+
+#### Advanced Settings ####
+
+## Message Display Time | https://docs.linuxgsm.com/features/message-display-time
+sleeptime="0.5"
+
+## Stop Mode | https://docs.linuxgsm.com/features/stop-mode
+# 1: tmux kill
+# 2: CTRL+c
+# 3: quit
+# 4: quit 120s
+# 5: stop
+# 6: q
+# 7: exit
+# 8: 7 Days to Die
+# 9: GoldSrc
+# 10: Avorion
+# 11: end
+stopmode="5"
+
+## Query mode
+# 1: session only
+# 2: gamedig (gsquery fallback)
+# 3: gamedig
+# 4: gsquery
+# 5: tcp
+querymode="2"
+querytype="minecraft"
+
+## Console type
+consoleverbose="yes"
+consoleinteract="yes"
+
+## Game Server Details
+# Do not edit
+gamename="PaperMC"
+engine="lwjgl2"
+glibc="null"
+
+#### Directories ####
+# Edit with care
+
+## Game Server Directories
+systemdir="${serverfiles}"
+executabledir="${serverfiles}"
+preexecutable="java -Xmx${javaram}M -jar"
+executable="./paper.jar"
+servercfgdir="${systemdir}"
+servercfg="server.properties"
+servercfgdefault="server.properties"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+
+## Backup Directory
+backupdir="${lgsmdir}/backup"
+
+## Logging Directories
+logdir="${rootdir}/log"
+gamelogdir="${systemdir}/logs"
+lgsmlogdir="${logdir}/script"
+consolelogdir="${logdir}/console"
+lgsmlog="${lgsmlogdir}/${selfname}-script.log"
+consolelog="${consolelogdir}/${selfname}-console.log"
+alertlog="${lgsmlogdir}/${selfname}-alert.log"
+postdetailslog="${lgsmlogdir}/${selfname}-postdetails.log"
+
+## Logs Naming
+lgsmlogdate="${lgsmlogdir}/${selfname}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
+consolelogdate="${consolelogdir}/${selfname}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"

+ 173 - 0
lgsm/config-default/config-lgsm/wmcserver/_default.cfg

@@ -0,0 +1,173 @@
+##################################
+######## Default Settings ########
+##################################
+# DO NOT EDIT, ANY CHANGES WILL BE OVERWRITTEN!
+# Copy settings from here and use them in either:
+# common.cfg - applies settings to every instance.
+# [instance].cfg - applies settings to a specific instance.
+
+#### Game Server Settings ####
+
+## Predefined Parameters | https://docs.linuxgsm.com/configuration/start-parameters
+javaram="1024" # -Xmx$1024M
+
+## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
+startparameters="nogui"
+
+## Release Settings | https://docs.linuxgsm.com/game-servers/minecraft#release-settings
+# Version (latest|1.16.5)
+mcversion="latest"
+
+#### LinuxGSM Settings ####
+
+## LinuxGSM Stats
+# Send useful stats to LinuxGSM developers.
+# https://docs.linuxgsm.com/configuration/linuxgsm-stats
+# (on|off)
+stats="off"
+
+## Notification Alerts
+# (on|off)
+
+# Display IP | https://docs.linuxgsm.com/alerts#display-ip
+displayip=""
+
+# More info | https://docs.linuxgsm.com/alerts#more-info
+postalert="off"
+
+# Discord Alerts | https://docs.linuxgsm.com/alerts/discord
+discordalert="off"
+discordwebhook="webhook"
+
+# Email Alerts | https://docs.linuxgsm.com/alerts/email
+emailalert="off"
+email="email@example.com"
+emailfrom=""
+
+# IFTTT Alerts | https://docs.linuxgsm.com/alerts/ifttt
+iftttalert="off"
+ifttttoken="accesstoken"
+iftttevent="linuxgsm_alert"
+
+# Mailgun Email Alerts | https://docs.linuxgsm.com/alerts/mailgun
+mailgunalert="off"
+mailgunapiregion="us"
+mailguntoken="accesstoken"
+mailgundomain="example.com"
+mailgunemailfrom="alert@example.com"
+mailgunemail="email@myemail.com"
+
+# Pushbullet Alerts | https://docs.linuxgsm.com/alerts/pushbullet
+pushbulletalert="off"
+pushbullettoken="accesstoken"
+channeltag=""
+
+# Pushover Alerts | https://docs.linuxgsm.com/alerts/pushover
+pushoveralert="off"
+pushovertoken="accesstoken"
+pushoveruserkey="userkey"
+
+# Rocket.Chat Alerts | https://docs.linuxgsm.com/alerts/rocket.chat
+rocketchatalert="off"
+rocketchatwebhook="webhook"
+rocketchattoken=""
+
+# Slack Alerts | https://docs.linuxgsm.com/alerts/slack
+slackalert="off"
+slackwebhook="webhook"
+
+# Telegram Alerts | https://docs.linuxgsm.com/alerts/telegram
+# You can add a custom cURL string eg proxy (useful in Russia) in "curlcustomstring".
+# For example "--socks5 ipaddr:port" for socks5 proxy see more in "curl --help".
+telegramapi="api.telegram.org"
+telegramalert="off"
+telegramtoken="accesstoken"
+telegramchatid=""
+curlcustomstring=""
+
+## Updating | https://docs.linuxgsm.com/commands/update
+updateonstart="off"
+
+## Backup | https://docs.linuxgsm.com/commands/backup
+maxbackups="4"
+maxbackupdays="30"
+stoponbackup="on"
+
+## Logging | https://docs.linuxgsm.com/features/logging
+consolelogging="on"
+logdays="7"
+
+## Monitor | https://docs.linuxgsm.com/commands/monitor
+# Query delay time
+querydelay="1"
+
+## ANSI Colors | https://docs.linuxgsm.com/features/ansi-colors
+ansi="on"
+
+#### Advanced Settings ####
+
+## Message Display Time | https://docs.linuxgsm.com/features/message-display-time
+sleeptime="0.5"
+
+## Stop Mode | https://docs.linuxgsm.com/features/stop-mode
+# 1: tmux kill
+# 2: CTRL+c
+# 3: quit
+# 4: quit 120s
+# 5: stop
+# 6: q
+# 7: exit
+# 8: 7 Days to Die
+# 9: GoldSrc
+# 10: Avorion
+# 11: end
+stopmode="2"
+
+## Query mode
+# 1: session only
+# 2: gamedig (gsquery fallback)
+# 3: gamedig
+# 4: gsquery
+# 5: tcp
+querymode="2"
+querytype="minecraft"
+
+## Console type
+consoleverbose="yes"
+consoleinteract="yes"
+
+## Game Server Details
+# Do not edit
+gamename="WaterfallMC"
+engine="lwjgl2"
+glibc="null"
+
+#### Directories ####
+# Edit with care
+
+## Game Server Directories
+systemdir="${serverfiles}"
+executabledir="${serverfiles}"
+preexecutable="java -Xmx${javaram}M -jar"
+executable="./waterfall.jar"
+servercfgdir="${systemdir}"
+servercfg="config.yml"
+servercfgdefault="config.yml"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+
+## Backup Directory
+backupdir="${lgsmdir}/backup"
+
+## Logging Directories
+logdir="${rootdir}/log"
+gamelogdir="${systemdir}/logs"
+lgsmlogdir="${logdir}/script"
+consolelogdir="${logdir}/console"
+lgsmlog="${lgsmlogdir}/${selfname}-script.log"
+consolelog="${consolelogdir}/${selfname}-console.log"
+alertlog="${lgsmlogdir}/${selfname}-alert.log"
+postdetailslog="${lgsmlogdir}/${selfname}-postdetails.log"
+
+## Logs Naming
+lgsmlogdate="${lgsmlogdir}/${selfname}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
+consolelogdate="${consolelogdir}/${selfname}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"

+ 2 - 0
lgsm/data/serverlist.csv

@@ -68,6 +68,7 @@ ns2c,ns2cserver,NS2: Combat
 onset,onsetserver,Onset
 opfor,opforserver,Opposing Force
 pc,pcserver,Project Cars
+pmc,pmcserver,PaperMC
 pstbs,pstbsserver,Post Scriptum: The Bloody Seventh
 pvkii,pvkiiserver,Pirates Vikings & Knights II
 pvr,pvrserver,Pavlov VR
@@ -110,6 +111,7 @@ vs,vsserver,Vampire Slayer
 vints,vintsserver,Vintage Story
 wet,wetserver,Wolfenstein: Enemy Territory
 wf,wfserver,Warfork
+wmc,wmcserver,WaterfallMC
 wurm,wurmserver,Wurm Unlimited
 zmr,zmrserver,Zombie Master: Reborn
 zps,zpsserver,Zombie Panic! Source

+ 3 - 3
lgsm/functions/check_deps.sh

@@ -347,7 +347,7 @@ fn_deps_build_debian(){
 	array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python3 tar bzip2 gzip unzip binutils bc jq tmux netcat cpio )
 
 	# All servers except ts3, mumble, GTA and minecraft servers require lib32stdc++6 and lib32gcc1.
-	if [ "${shortname}" != "ts3" ]&&[ "${shortname}" != "mumble" ]&&[ "${shortname}" != "mc" ]&&[ "${engine}" != "renderware" ]; then
+	if [ "${shortname}" != "ts3" ]&&[ "${shortname}" != "mumble" ]&&[ "${shortname}" != "mc" ]&&[ "${shortname}" != "pmc" ]&&[ "${shortname}" != "wmc" ]&&[ "${engine}" != "renderware" ]; then
 		if [ "${arch}" == "x86_64" ]; then
 			# lib32gcc1 is now called lib32gcc-s1 in debian 11
 			if { [ "${distroid}" == "debian" ]&&[ "${distroversion}" == "11" ]; }|| { [ "${distroid}" == "ubuntu" ]&&[ "${distroversion}" == "20.10" ]; } ||{ [ "${distroid}" == "pop" ]&&[ "${distroversion}" == "20.10" ]; }; then
@@ -415,7 +415,7 @@ fn_deps_build_debian(){
 	elif [ "${shortname}" == "hw" ]||[ "${shortname}" == "rust" ]; then
 		array_deps_required+=( lib32z1 )
 	# Minecraft, Rising World, Wurm
-	elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "rw" ]; then
+	elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]||[ "${shortname}" == "wmc" ]||[ "${shortname}" == "rw" ]; then
 		javaversion=$(java -version 2>&1 | grep "version")
 		if [ "${javaversion}" ]; then
 			# Added for users using Oracle JRE to bypass the check.
@@ -533,7 +533,7 @@ fn_deps_build_redhat(){
 	elif [ "${shortname}" == "hw" ]||[ "${shortname}" == "rust" ]; then
 		array_deps_required+=( zlib-devel )
 	# Minecraft, Rising World, Wurm
-	elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "rw" ]; then
+	elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]||[ "${shortname}" == "wmc" ]||[ "${shortname}" == "rw" ]; then
 		javaversion=$(java -version 2>&1 | grep "version")
 		if [ "${javaversion}" ]; then
 			# Added for users using Oracle JRE to bypass the check.

+ 1 - 1
lgsm/functions/check_system_requirements.sh

@@ -26,7 +26,7 @@ elif [ "${shortname}" == "arma3" ]; then
 elif [ "${shortname}" == "rust" ]; then
 	ramrequirementmb="4000"
 	ramrequirementgb="4"
-elif [ "${shortname}" == "mc" ]; then
+elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]||[ "${shortname}" == "wmc" ]; then
 	ramrequirementmb="1000"
 	ramrequirementgb="1"
 elif [ "${shortname}" == "pstbs" ]; then

+ 2 - 0
lgsm/functions/command_update.sh

@@ -21,6 +21,8 @@ elif [ "${shortname}" == "mc" ]; then
 	update_minecraft.sh
 elif [ "${shortname}" == "mcb" ]; then
 	update_minecraft_bedrock.sh
+elif [ "${shortname}" == "pmc" ]||[ "${shortname}" == "wmc" ]; then
+	update_papermc.sh
 elif [ "${shortname}" == "mumble" ]; then
 	update_mumble.sh
 elif [ "${shortname}" == "fctr" ]; then

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -644,6 +644,11 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 }
 
+update_papermc.sh(){
+functionfile="${FUNCNAME[0]}"
+fn_fetch_function
+}
+
 update_mumble.sh(){
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function

+ 25 - 1
lgsm/functions/info_config.sh

@@ -1565,6 +1565,28 @@ fn_info_config_scpsl(){
 	fi
 }
 
+fn_info_config_waterfall(){
+	if [ -f "${servercfgfullpath}" ]; then
+		servername=$(sed -e '/^listeners:/,/^[a-z]/!d' "${servercfgfullpath}" | sed -nr 's/^[ ]+motd: (.*)$/\1/p' | tr -d "'" | sed 's/&1//')
+		queryport=$(sed -nr 's/^[ -]+query_port: ([0-9]+)/\1/p' "${servercfgfullpath}")
+		queryenabled=$(sed -nr 's/^[ ]+query_enabled: (.*)$/\1/p' "${servercfgfullpath}")
+		port=$(sed -nr 's/^[ ]+host: [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:([0-9]+)/\1/p' "${servercfgfullpath}")
+		# the normal max_players does only show in on the client side and has no effect how many players can connect
+		maxplayers=$(sed -nr 's/^player_limit: ([-]*[0-9])/\1/p' "${servercfgfullpath}")
+		configip=$(sed -nr 's/^[ ]+host: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+):[0-9]+/\1/p' "${servercfgfullpath}")
+
+		if [ "${maxplayers}" == "-1" ]||[ "${maxplayers}" == "0" ]; then
+			maxplayers="UNLIMITED"
+		fi
+	else
+		servername="${unavailable}"
+		maxplayers="${zero}"
+		port="${zero}"
+		queryport="${zero}"
+		queryenabled="${unavailable}"
+	fi
+}
+
 if [ "${shortname}" == "ac" ]; then
 	fn_info_config_assettocorsa
 elif [ "${shortname}" == "ark" ]; then
@@ -1619,7 +1641,7 @@ elif [ "${shortname}" == "ql" ]; then
 	fn_info_config_quakelive
 elif [ "${shortname}" == "jk2" ]; then
 	fn_info_config_jk2
-elif [ "${shortname}" == "mc" ]; then
+elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]; then
 	fn_info_config_minecraft
 elif [ "${shortname}" == "mcb" ]; then
 	fn_info_config_minecraft_bedrock
@@ -1691,4 +1713,6 @@ elif [ "${shortname}" == "pvr" ];then
 	fn_info_config_pavlovvr
 elif [ "${shortname}" == "vints" ]; then
 	fn_info_config_vintagestory
+elif [ "${shortname}" == "wmc" ]; then
+	fn_info_config_waterfall
 fi

+ 1 - 1
lgsm/functions/info_messages.sh

@@ -1540,7 +1540,7 @@ fn_info_message_select_engine(){
 		fn_info_message_justcause3
 	elif [ "${shortname}" == "kf2" ]; then
 		fn_info_message_kf2
-	elif [ "${shortname}" == "mc" ]; then
+	elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]||[ "${shortname}" == "wmc" ]; then
 		fn_info_message_minecraft
 	elif [ "${shortname}" == "mcb" ]; then
 		fn_info_message_minecraft_bedrock

+ 7 - 1
lgsm/functions/install_config.sh

@@ -514,7 +514,7 @@ elif [ "${shortname}" == "l4d2" ]; then
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
-elif [ "${shortname}" == "mc" ]; then
+elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]; then
 	gamedirname="Minecraft"
 	array_configs+=( server.properties )
 	fn_fetch_default_config
@@ -829,6 +829,12 @@ elif [ "${shortname}" == "wf" ]; then
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_list_config_locations
+elif [ "${shortname}" == "wmc" ]; then
+	gamedirname="Waterfall"
+	array_configs+=( config.yml )
+	fn_fetch_default_config
+	fn_default_config_remote
+	fn_set_config_vars
 elif [ "${shortname}" == "wurm" ]; then
 	gamedirname="WurmUnlimited"
 	array_configs+=( server.cfg )

+ 2 - 2
lgsm/functions/install_eula.sh

@@ -9,7 +9,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 if [ "${shortname}" == "ts3" ]; then
 	eulaurl="https://www.teamspeak.com/en/privacy-and-terms"
-elif [ "${shortname}" == "mc" ]; then
+elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]||[ "${shortname}" == "wmc" ]; then
 	eulaurl="https://account.mojang.com/documents/minecraft_eula"
 elif [ "${shortname}" == "ut" ]; then
 	eulaurl="https://www.epicgames.com/unrealtournament/unreal-tournament-pre-alpha-test-development-build-eula"
@@ -41,7 +41,7 @@ fi
 
 if [ "${shortname}" == "ts3" ]; then
 	touch "${executabledir}/.ts3server_license_accepted"
-elif [ "${shortname}" == "mc" ]; then
+elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "pmc" ]; then
 	touch "${serverfiles}/eula.txt"
 	echo -e "eula=true" > "${serverfiles}/eula.txt"
 elif [ "${shortname}" == "ut" ]; then

+ 6 - 0
lgsm/functions/install_server_files.sh

@@ -83,6 +83,12 @@ elif [ "${shortname}" == "mc" ]; then
 	update_minecraft.sh
 elif [ "${shortname}" == "mcb" ]; then
 	update_minecraft_bedrock.sh
+elif [ "${shortname}" == "pmc" ]; then
+	install_eula.sh
+	update_papermc.sh
+elif [ "${shortname}" == "wmc" ]; then
+	install_eula.sh
+	update_papermc.sh
 elif [ "${shortname}" == "mumble" ]; then
 	update_mumble.sh
 elif [ "${shortname}" == "mta" ]; then

+ 160 - 0
lgsm/functions/update_papermc.sh

@@ -0,0 +1,160 @@
+#!/bin/bash
+# LinuxGSM update_papermc.sh function
+# Author: Daniel Gibbs
+# Contributors: http://linuxgsm.com/contrib
+# Website: https://linuxgsm.com
+# Description: Handles updating of PaperMC and Waterfall servers.
+
+local commandname="UPDATE"
+local commandaction="Update"
+local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+fn_update_papermc_dl(){
+	# get build info
+	builddata=$(curl -s "https://${remotelocation}/api/v2/projects/${paperproject}/versions/${paperversion}/builds/${remotebuild}" | jq '.downloads' )
+	buildname=$(echo -e "${builddata}" | jq -r '.application.name')
+	buildsha256=$(echo -e "${builddata}" | jq -r '.application.sha256')
+
+	fn_fetch_file "https://${remotelocation}/api/v2/projects/${paperproject}/versions/${paperversion}/builds/${remotebuild}/downloads/${buildname}" "" "" "" "${tmpdir}" "${buildname}" "nochmodx" "norun" "force" "${buildsha256}"
+
+	echo -e "copying to ${serverfiles}...\c"
+	cp -f "${tmpdir}/${buildname}" "${serverfiles}/${executable#./}"
+	local exitcode=$?
+	if [ "${exitcode}" == "0" ]; then
+		fn_print_ok_eol_nl
+		fn_script_log_pass "Copying to ${serverfiles}"
+		chmod u+x "${serverfiles}/${executable#./}"
+		echo "${remotebuild}" > "${localversionfile}"
+		fn_clear_tmp
+	else
+		fn_print_fail_eol_nl
+		fn_script_log_fatal "Copying to ${serverfiles}"
+		core_exit.sh
+	fi
+}
+
+fn_update_papermc_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking for update: ${remotelocation}: checking local build"
+	sleep 0.5
+
+	if [ ! -f "${localversionfile}" ]; then
+		fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no local build files"
+		fn_script_log_error "No local build file found"
+	else
+		localbuild=$(head -n 1 "${localversionfile}")
+	fi
+
+	if [ -z "${localbuild}" ]; then
+		localbuild="0"
+		fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info"
+		fn_script_log_error "Missing local build info, Set localbuild to 0"
+	else
+		fn_print_ok "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_pass "Checking local build"
+	fi
+	sleep 0.5
+}
+
+fn_update_papermc_remotebuild(){
+	# Gets remote build info.
+	remotebuild=$(curl -s "https://${remotelocation}/api/v2/projects/${paperproject}/versions/${paperversion}" | jq -r '.builds[-1]')
+
+	# Checks if remotebuild variable has been set.
+	if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+		fn_print_failure "Unable to get remote build"
+		fn_script_log_fatal "Unable to get remote build"
+		core_exit.sh
+	else
+		fn_print_ok "Got build for version ${paperversion}"
+		fn_script_log "Got build for version ${paperversion}"
+	fi
+}
+
+fn_update_papermc_compare(){
+	fn_print_dots "Checking for update: ${remotelocation}"
+	sleep 0.5
+	if [ "${localbuild}" != "${remotebuild}" ]||[ "${forceupdate}" == "1" ]; then		
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		echo -en "\n"
+		echo -e "Update available for version ${paperversion}"
+		echo -e "* Local build: ${red}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "Update available for version ${paperversion}"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
+		echo -en "\n"
+		echo -en "applying update.\r"
+		echo -en "\n"
+
+		unset updateonstart
+
+		check_status.sh
+		# If server stopped.
+		if [ "${status}" == "0" ]; then
+			fn_update_papermc_dl
+		# If server started.
+		else
+			exitbypass=1
+			command_stop.sh
+			exitbypass=1
+			fn_update_papermc_dl
+			exitbypass=1
+			command_start.sh
+		fi
+		alert="update"
+		alert.sh
+	else
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		echo -en "\n"
+		echo -e "No update available for version ${paperversion}"
+		echo -e "* Local build: ${green}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+	fi
+}
+
+# The location where the builds are checked and downloaded.
+remotelocation="papermc.io"
+
+if [ "${shortname}" == "pmc" ]; then
+	paperproject="paper"
+elif [ "${shortname}" == "wmc" ]; then
+	paperproject="waterfall"
+fi
+
+localversionfile="${datadir}/${paperproject}-version"
+
+# check if datadir was created, if not create it
+if [ ! -d "${datadir}" ]; then
+	mkdir -p "${datadir}"
+fi
+
+# check version if the user did set one and check it
+if [ "${mcversion}" == "latest" ]; then
+	paperversion=$(curl -s "https://${remotelocation}/api/v2/projects/${paperproject}" | jq -r '.versions[-1]')
+else
+	# check if version there for the download from the api
+	paperversion=$(curl -s "https://${remotelocation}/api/v2/projects/${paperproject}" | jq -r -e --arg mcversion "${mcversion}" '.versions[]|select(. == $mcversion)')
+	if [ -z "${paperversion}" ]; then
+		# user passed version does not exist
+		fn_print_error_nl "Version ${mcversion} not available from ${remotelocation}"
+		fn_script_log_error "Version ${mcversion} not available from ${remotelocation}"
+		core_exit.sh
+	fi
+fi
+
+if [ "${firstcommandname}" == "INSTALL" ]; then
+	fn_update_papermc_remotebuild
+	fn_update_papermc_dl
+else
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
+	sleep 0.5
+	fn_update_papermc_localbuild
+	fn_update_papermc_remotebuild
+	fn_update_papermc_compare
+fi