From 7b6b6d57089851981a9fe911e54813f30ae33fb7 Mon Sep 17 00:00:00 2001 From: anaxios Date: Wed, 2 Jul 2025 22:02:43 -0700 Subject: [PATCH] add new commands for status endpoints --- mc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mc b/mc index 2b3e069..abd3607 100755 --- a/mc +++ b/mc @@ -20,6 +20,9 @@ declare -rA commands=( [list-players]='GET' [website]='GET' [map]='GET' + [status-minecraft]='GET' + [status-bedrock]='GET' + [status-sftp]='GET' [ban]='POST {"username": "%s"}' [unban]='POST {"username": "%s"}' [say]='POST {"message": "%s"}' @@ -42,6 +45,16 @@ function rest() { fi } +function status_format() { + local tmp=(${1//-/ }) + local second=${tmp[1]} + if [[ "$second" == "sftp" ]]; then + printf "${second^^}" + return + fi + printf "${second^}" +} + function usage() { printf "API key for my-mc must be exported using 'export MY_MC_API_KEY='\n\n" printf "Positional arguments will fill the JSON objects with values from left to right.\n\n" @@ -61,6 +74,9 @@ for command in "${!commands[@]}"; do if [[ "$(first "${commands[$1]}")" == "POST" ]]; then curl -sS "${headers[@]}" -X "$(first "${commands[$1]}")" "${base_url}${command}" -d "$(printf "$(rest ${commands[$1]})\n" "${args[@]}")" echo "" + elif [[ "${command}" =~ ^"status" ]]; then + curl -sS "${headers[@]}" -X "$(first "${commands[$1]}")" "${base_url}status/$(status_format ${command})" + echo "" else curl -sS "${headers[@]}" -X "$(first "${commands[$1]}")" "${base_url}${command}" echo ""