From dfebbd022e489eff474b0bdb76b44a712b6df240 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sun, 4 Jun 2023 12:07:33 +0200 Subject: [PATCH] new: [minecraft] support of ``properties`` option Notice that ``whitelist`` related ``properties`` will be overriden to make sure it is taken into account. To disable whitelist, simply remove it by commenting the ``whitelist`` full entry in your service ``options``. --- minecraft/hooks/init | 10 ++++++++++ minecraft/lib/common | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/minecraft/hooks/init b/minecraft/hooks/init index 8612831..a050204 100755 --- a/minecraft/hooks/init +++ b/minecraft/hooks/init @@ -24,9 +24,19 @@ mem=$(options-get mem) || exit 1 minecraft:init-command "$threads" "$mem" +properties=$(options-get properties) || true whitelist=$(options-get whitelist) || true minecraft:make-whitelist "$whitelist" +if [ -n "$whitelist" ]; then + properties="$( + e "$properties" | + yq '.white-list = true, .enforce-whitelist = true' + )" +fi + ops=$(options-get ops) || true minecraft:make-ops "$ops" + +minecraft:make-properties "$properties" diff --git a/minecraft/lib/common b/minecraft/lib/common index d9f7102..b408405 100644 --- a/minecraft/lib/common +++ b/minecraft/lib/common @@ -63,4 +63,14 @@ minecraft:make-ops() { "bypassesPlayerLimit": .value.bypassesPlayerLimit })' } > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/ops.json" -} \ No newline at end of file +} + +minecraft:make-properties() { + local properties="$1" + + { + e "$properties" | + yq 'to_entries | map(.key + "=" + .value) | .[]' + } > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/server.properties" +} +