Added UUID Support for WHITELIST (#1139)

This commit is contained in:
Kyle 2021-12-02 03:12:58 +00:00 committed by GitHub
parent 263a10848a
commit 75dcc746f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -846,8 +846,14 @@ To whitelist players for your Minecraft server, pass the Minecraft usernames sep
docker run -d -e WHITELIST=user1,user2 ... docker run -d -e WHITELIST=user1,user2 ...
or
docker run -d -e WHITELIST=uuid1,uuid2 ...
If the `WHITELIST` environment variable is not used, any user can join your Minecraft server if it's publicly accessible. If the `WHITELIST` environment variable is not used, any user can join your Minecraft server if it's publicly accessible.
> NOTE: When using uuids in the whitelist, please make sure it is the dashed variant otherwise it will not parse correctly.
> NOTE: When `WHITELIST` is used the server properties `white-list` and `whitelist` will automatically get set to `true`. > NOTE: When `WHITELIST` is used the server properties `white-list` and `whitelist` will automatically get set to `true`.
> By default, the players in `WHITELIST` are **added** to the final `whitelist.json` file by the Minecraft server. If you set `OVERRIDE_WHITELIST` to "true" then the `whitelist.json` file will be recreated on each server startup. > By default, the players in `WHITELIST` are **added** to the final `whitelist.json` file by the Minecraft server. If you set `OVERRIDE_WHITELIST` to "true" then the `whitelist.json` file will be recreated on each server startup.

View File

@ -16,8 +16,12 @@ fi
if [ -n "$WHITELIST" ]; then if [ -n "$WHITELIST" ]; then
log "Updating whitelist" log "Updating whitelist"
rm -f /data/white-list.txt.converted rm -f /data/white-list.txt.converted
if [[ $WHITELIST == *"-"* ]]; then
echo $WHITELIST | awk -v RS=, '{print}' | xargs -l -i curl -s https://playerdb.co/api/player/minecraft/{} | jq -r '.["data"]["player"] | {"uuid": .id, "name": .username}' | jq -s . > "whitelist.json"
else
echo $WHITELIST | awk -v RS=, '{print}' > /data/white-list.txt echo $WHITELIST | awk -v RS=, '{print}' > /data/white-list.txt
fi fi
fi
if isTrue "${OVERRIDE_WHITELIST}"; then if isTrue "${OVERRIDE_WHITELIST}"; then
log "Recreating whitelist.json file at server startup" log "Recreating whitelist.json file at server startup"
rm -f /data/whitelist.json rm -f /data/whitelist.json