From 8e5c22e75a970593eac6c1b9002462853e1a6ab8 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 19 Jun 2023 16:44:18 +0200 Subject: [PATCH] new: [minecraft] add type of install and ``paper`` type --- minecraft/README.org | 30 ++++++++++++++++++++++++++++++ minecraft/hooks/init | 3 ++- minecraft/lib/common | 24 ++++++++++++++++++------ 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 minecraft/README.org diff --git a/minecraft/README.org b/minecraft/README.org new file mode 100644 index 0000000..272e796 --- /dev/null +++ b/minecraft/README.org @@ -0,0 +1,30 @@ +* Usage + +#+begin_src yaml +minecraft: + options: + type: paper ## legacy or paper + version: 1.20.1-32 + threads: 8 + mem: 2048M + properties: + gamemode: survival + view-distance: 16 + ops: + foo: + uuid: 7217ab76-1b23-4884-9072-d81f63ef6c23 + level: 4 + bypassesPlayerLimit: false + whitelist: + 7217ab76-1b23-4884-9072-d81f63ef6c23: foo + 8481e720-33fa-48b2-a3be-610e81bae897: bar +#+end_src + +* Version + +The version option provided should be: +- For =type= ~paper~ any released version found on their website. +- For =type= ~legacy~ (default value), should be one of the following + version: ~1.6.2~, ~1.7.2~, ~1.7.9~, ~1.8.1~, ~1.8~, ~1.9.4~, + ~1.10.2~, ~1.10~, ~1.11.2~, ~1.11~, ~1.12.1~, ~1.12.2~, ~1.12~, + ~1.13.1~, ~1.13.2~, ~1.13~, ~1.19.4~, ~1.20.0~ diff --git a/minecraft/hooks/init b/minecraft/hooks/init index c4c3193..79f2233 100755 --- a/minecraft/hooks/init +++ b/minecraft/hooks/init @@ -16,8 +16,9 @@ set -e version=$(options-get version) || exit 1 +type=$(options-get type) || exit 1 -minecraft:init-binary "$version" +minecraft:init-binary "${type:-legacy}" "$version" threads=$(options-get threads) || exit 1 mem=$(options-get mem) || exit 1 diff --git a/minecraft/lib/common b/minecraft/lib/common index 6777398..8bf178b 100644 --- a/minecraft/lib/common +++ b/minecraft/lib/common @@ -5,18 +5,30 @@ MINECRAFT_PATH="$SERVICE_CONFIGSTORE/opt/apps/minecraft" MINECRAFT_DATA="/var/lib/minecraft" minecraft:init-binary() { - local version="$1" - - MINECRAFT_BINARY="${MINECRAFT_PATH}/minecraft_server.${version}.jar" + local type="$1" version="$2" + + case "$type" in + "legacy") + MINECRAFT_URL="https://docker.0k.io/downloads/minecraft_server.${version}.jar" + MINECRAFT_BINARY="minecraft_server.${version}.jar" + ;; + "paper") + MINECRAFT_URL="https://api.papermc.io/v2/projects/paper/versions/${version%-*}/builds/${version##*-}/downloads/paper-${version}.jar" + MINECRAFT_BINARY="paper.${version}.jar" + ;; + *) + err "Unknown ${WHITE}type${NORMAL} '$type'. Please use on of: legacy, paper" + exit 1 + ;; + esac if ! [ -f "$MINECRAFT_BINARY" ]; then mkdir -p "${MINECRAFT_PATH}" - wget "https://docker.0k.io/downloads/minecraft_server.${version}.jar" \ - -O "$MINECRAFT_BINARY" + wget "$MINECRAFT_URL" -O "$MINECRAFT_PATH/$MINECRAFT_BINARY" || exit 1 fi init-config-add " $SERVICE_NAME: volumes: - - \"${MINECRAFT_BINARY}:${MINECRAFT_DATA}/server.jar\" + - \"$MINECRAFT_PATH/${MINECRAFT_BINARY}:${MINECRAFT_DATA}/server.jar\" " }