playerdb.co/api
This commit is contained in:
parent
b672fc608c
commit
73d0f379a4
1 changed files with 44 additions and 38 deletions
82
launch.sh
82
launch.sh
|
|
@ -7,32 +7,32 @@ SERVER_VERSION=2.24
|
|||
cd /data
|
||||
|
||||
if ! [[ "$EULA" = "false" ]]; then
|
||||
echo "eula=true" > eula.txt
|
||||
echo "eula=true" > eula.txt
|
||||
else
|
||||
echo "You must accept the EULA to install."
|
||||
exit 99
|
||||
echo "You must accept the EULA to install."
|
||||
exit 99
|
||||
fi
|
||||
|
||||
if ! [[ -f "Server-Files-$SERVER_VERSION.zip" ]]; then
|
||||
rm -fr config defaultconfigs kubejs mods packmenu Simple.zip forge*
|
||||
curl -Lo "Server-Files-$SERVER_VERSION.zip" 'https://edge.forgecdn.net/files/6088/026/ServerFiles-2.24.zip' || exit 9
|
||||
unzip -u -o "Server-Files-$SERVER_VERSION.zip" -d /data
|
||||
DIR_TEST=$(find . -type d -maxdepth 1 | tail -1 | sed 's/^.\{2\}//g')
|
||||
if [[ $(find . -type d -maxdepth 1 | wc -l) -gt 1 ]]; then
|
||||
cd "${DIR_TEST}"
|
||||
find . -type d -exec chmod 777 {} +
|
||||
mv -f * /data
|
||||
cd /data
|
||||
rm -fr "$DIR_TEST"
|
||||
fi
|
||||
|
||||
curl -Lo neoforge-${NEOFORGE_VERSION}-installer.jar https://maven.neoforged.net/releases/net/neoforged/neoforge/$NEOFORGE_VERSION/neoforge-$NEOFORGE_VERSION-installer.jar
|
||||
java -jar neoforge-${NEOFORGE_VERSION}-installer.jar --installServer
|
||||
rm -fr config defaultconfigs kubejs mods packmenu Simple.zip forge*
|
||||
curl -Lo "Server-Files-$SERVER_VERSION.zip" 'https://edge.forgecdn.net/files/6088/026/ServerFiles-2.24.zip' || exit 9
|
||||
unzip -u -o "Server-Files-$SERVER_VERSION.zip" -d /data
|
||||
DIR_TEST=$(find . -type d -maxdepth 1 | tail -1 | sed 's/^.\{2\}//g')
|
||||
if [[ $(find . -type d -maxdepth 1 | wc -l) -gt 1 ]]; then
|
||||
cd "${DIR_TEST}"
|
||||
find . -type d -exec chmod 777 {} +
|
||||
mv -f * /data
|
||||
cd /data
|
||||
rm -fr "$DIR_TEST"
|
||||
fi
|
||||
|
||||
curl -Lo neoforge-${NEOFORGE_VERSION}-installer.jar https://maven.neoforged.net/releases/net/neoforged/neoforge/$NEOFORGE_VERSION/neoforge-$NEOFORGE_VERSION-installer.jar
|
||||
java -jar neoforge-${NEOFORGE_VERSION}-installer.jar --installServer
|
||||
fi
|
||||
|
||||
if [[ -n "$JVM_OPTS" ]]; then
|
||||
sed -i '/-Xm[s,x]/d' user_jvm_args.txt
|
||||
for j in ${JVM_OPTS}; do sed -i '$a\'$j'' user_jvm_args.txt; done
|
||||
sed -i '/-Xm[s,x]/d' user_jvm_args.txt
|
||||
for j in ${JVM_OPTS}; do sed -i '$a\'$j'' user_jvm_args.txt; done
|
||||
fi
|
||||
if [[ -n "$MOTD" ]]; then
|
||||
sed -i "s/^motd=.*/motd=$MOTD/" /data/server.properties
|
||||
|
|
@ -49,43 +49,49 @@ fi
|
|||
if [[ -n "$ONLINE_MODE" ]]; then
|
||||
sed -i "s/online-mode=.*/online-mode=$ONLINE_MODE/" /data/server.properties
|
||||
fi
|
||||
|
||||
# Initialize whitelist
|
||||
echo "[]" > whitelist.json
|
||||
IFS=',' read -ra USERS <<< "$WHITELIST_USERS"
|
||||
for raw_username in "${USERS[@]}"; do
|
||||
username=$(echo "$raw_username" | xargs)
|
||||
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
|
||||
echo "Whitelist: Invalid username: '$username'. Skipping..."
|
||||
continue
|
||||
fi
|
||||
username=$(echo "$raw_username" | xargs)
|
||||
|
||||
UUID=$(curl -s "https://api.minetools.eu/uuid/$username" | jq -r '.id')
|
||||
if [[ "$UUID" != "null" ]]; then
|
||||
if jq -e ".[] | select(.uuid == \"$UUID\")" whitelist.json > /dev/null; then
|
||||
echo "Whitelist: $username ($UUID) is already whitelisted."
|
||||
else
|
||||
UUID=$(echo "$UUID" | sed -r 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')
|
||||
echo "Whitelist: Adding $username ($UUID) to whitelist."
|
||||
jq ". += [{\"uuid\": \"$UUID\", \"name\": \"$username\"}]" whitelist.json > tmp.json && mv tmp.json whitelist.json
|
||||
fi
|
||||
else
|
||||
echo "Whitelist: Failed to fetch UUID for $username."
|
||||
fi
|
||||
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
|
||||
echo "Whitelist: Invalid username: '$username'. Skipping..."
|
||||
continue
|
||||
fi
|
||||
|
||||
UUID=$(curl -s "https://playerdb.co/api/player/minecraft/$username" | jq -r '.data.player.id')
|
||||
if [[ "$UUID" != "null" ]]; then
|
||||
if jq -e ".[] | select(.uuid == \"$UUID\")" whitelist.json > /dev/null; then
|
||||
echo "Whitelist: $username ($UUID) is already whitelisted."
|
||||
else
|
||||
UUID=$(echo "$UUID" | sed -r 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')
|
||||
echo "Whitelist: Adding $username ($UUID) to whitelist."
|
||||
jq ". += [{\"uuid\": \"$UUID\", \"name\": \"$username\"}]" whitelist.json > tmp.json && mv tmp.json whitelist.json
|
||||
fi
|
||||
else
|
||||
echo "Whitelist: Failed to fetch UUID for $username."
|
||||
fi
|
||||
done
|
||||
|
||||
# Initialize ops
|
||||
echo "[]" > ops.json
|
||||
IFS=',' read -ra OPS <<< "$OP_USERS"
|
||||
for raw_username in "${OPS[@]}"; do
|
||||
username=$(echo "$raw_username" | xargs)
|
||||
|
||||
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
|
||||
echo "Ops: Invalid username: '$username'. Skipping..."
|
||||
continue
|
||||
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 jq -e ".[] | select(.uuid == \"$UUID\")" ops.json > /dev/null; then
|
||||
echo "Ops: $username ($UUID) is already an operator."
|
||||
else
|
||||
UUID=$(echo "$UUID" | sed -r 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')
|
||||
UUID=$(echo "$UUID" | sed -r 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')
|
||||
echo "Ops: Adding $username ($UUID) as operator."
|
||||
jq ". += [{\"uuid\": \"$UUID\", \"name\": \"$username\", \"level\": 4, \"bypassesPlayerLimit\": false}]" ops.json > tmp.json && mv tmp.json ops.json
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue