From fd651aa3a2f8635a9e6b4133e1cf89ef63f27844 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sun, 4 Jun 2023 10:32:57 +0200 Subject: [PATCH] new: [minecraft] support of ``whitelist`` option --- minecraft/hooks/init | 6 +++++- minecraft/lib/common | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/minecraft/hooks/init b/minecraft/hooks/init index 626db1d..ef7f2a5 100755 --- a/minecraft/hooks/init +++ b/minecraft/hooks/init @@ -22,4 +22,8 @@ minecraft:init-binary "$version" threads=$(options-get threads) || exit 1 mem=$(options-get mem) || exit 1 -minecraft:init-command "$threads" "$mem" \ No newline at end of file +minecraft:init-command "$threads" "$mem" + + +whitelist=$(options-get whitelist) || true +minecraft:make-whitelist "$whitelist" diff --git a/minecraft/lib/common b/minecraft/lib/common index 12ea88b..b66a318 100644 --- a/minecraft/lib/common +++ b/minecraft/lib/common @@ -36,4 +36,16 @@ $SERVICE_NAME: - nogui " echo "eula=TRUE" > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/eula.txt" +} + + +minecraft:make-whitelist() { + local whitelist="$1" + + { + e "$whitelist" | + yq -o=json \ + 'to_entries | map({"uuid": .key, "name": .value})' + } > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/whitelist.json" + } \ No newline at end of file