playerdb.co/api

This commit is contained in:
Roger 2025-01-15 23:57:40 -05:00
parent 1a2c720c66
commit a3db683828

View file

@ -49,16 +49,19 @@ fi
if [[ -n "$ONLINE_MODE" ]]; then if [[ -n "$ONLINE_MODE" ]]; then
sed -i "s/online-mode=.*/online-mode=$ONLINE_MODE/" /data/server.properties sed -i "s/online-mode=.*/online-mode=$ONLINE_MODE/" /data/server.properties
fi fi
# Initialize whitelist
echo "[]" > whitelist.json echo "[]" > whitelist.json
IFS=',' read -ra USERS <<< "$WHITELIST_USERS" IFS=',' read -ra USERS <<< "$WHITELIST_USERS"
for raw_username in "${USERS[@]}"; do for raw_username in "${USERS[@]}"; do
username=$(echo "$raw_username" | xargs) username=$(echo "$raw_username" | xargs)
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
echo "Whitelist: Invalid username: '$username'. Skipping..." echo "Whitelist: Invalid username: '$username'. Skipping..."
continue continue
fi fi
UUID=$(curl -s "https://api.minetools.eu/uuid/$username" | jq -r '.id') UUID=$(curl -s "https://playerdb.co/api/player/minecraft/$username" | jq -r '.data.player.id')
if [[ "$UUID" != "null" ]]; then if [[ "$UUID" != "null" ]]; then
if jq -e ".[] | select(.uuid == \"$UUID\")" whitelist.json > /dev/null; then if jq -e ".[] | select(.uuid == \"$UUID\")" whitelist.json > /dev/null; then
echo "Whitelist: $username ($UUID) is already whitelisted." echo "Whitelist: $username ($UUID) is already whitelisted."
@ -71,16 +74,19 @@ for raw_username in "${USERS[@]}"; do
echo "Whitelist: Failed to fetch UUID for $username." echo "Whitelist: Failed to fetch UUID for $username."
fi fi
done done
# Initialize ops
echo "[]" > ops.json echo "[]" > ops.json
IFS=',' read -ra OPS <<< "$OP_USERS" IFS=',' read -ra OPS <<< "$OP_USERS"
for raw_username in "${OPS[@]}"; do for raw_username in "${OPS[@]}"; do
username=$(echo "$raw_username" | xargs) username=$(echo "$raw_username" | xargs)
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
echo "Ops: Invalid username: '$username'. Skipping..." echo "Ops: Invalid username: '$username'. Skipping..."
continue continue
fi fi
UUID=$(curl -s "https://api.minetools.eu/uuid/$username" | jq -r '.id') UUID=$(curl -s "https://playerdb.co/api/player/minecraft/$username" | jq -r '.data.player.id')
if [[ "$UUID" != "null" ]]; then if [[ "$UUID" != "null" ]]; then
if jq -e ".[] | select(.uuid == \"$UUID\")" ops.json > /dev/null; then if jq -e ".[] | select(.uuid == \"$UUID\")" ops.json > /dev/null; then
echo "Ops: $username ($UUID) is already an operator." echo "Ops: $username ($UUID) is already an operator."