Created
September 7, 2021 18:08
-
-
Save x86-39/ce7137f6dee7426440daa63decfdbaad to your computer and use it in GitHub Desktop.
Minecraft get profile shell command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to your .bashrc/.zshrc, or wherever you keep functions! | |
mc-get () | |
{ | |
LENGTH=$(echo ${1} | awk '{print length}' ) | |
if [[ $LENGTH -le 20 ]] || [[ $LENGTH -eq 32 ]] || [[ $LENGTH -eq 36 ]]; then | |
if [[ $(echo ${1} | sed 's,-,,g' | awk '{print length}' ) -eq 32 ]]; then | |
MCUUID=${1} | |
MCUSERNAME=$(curl -s https://api.mojang.com/user/profiles/${1}/names | jq ".[-1].name" | sed 's,",,g') | |
else | |
MCUSERNAME=${1} | |
MCUUID=$(curl -s https://api.mojang.com/users/profiles/minecraft/${1} | jq ".id" | sed 's,",,g') | |
fi | |
MCUSERNAME=$(curl -s https://api.mojang.com/users/profiles/minecraft/${MCUSERNAME} | jq ".name" | sed 's,",,g') | |
FORMATTED=$(if [[ $(echo ${MCUUID} | awk '{print length}') -eq 32 ]]; then echo ${MCUUID} | sed 's,^\(.\{8\}\)\(.\{4\}\)\(.\{4\}\)\(.\{4\}\),\1-\2-\3-\4-,'; else echo ${MCUUID}; fi) | |
UNFORMATTED=$(if [[ $(echo ${MCUUID} | awk '{print length}') -eq 36 ]]; then echo ${MCUUID} | sed 's,-,,g'; else echo ${MCUUID}; fi) | |
printf "\e[1;93mUsername: \e[0;32m${MCUSERNAME}\e[0m\n" | |
printf "\e[1;93mFormatted UUID: \e[0;32m${FORMATTED}\e[0m\n" | |
printf "\e[1;93mPlain UUID: \e[0;32m${UNFORMATTED}\e[0m\n" | |
printf "\n" | |
printf "\e[1;95mNameMC Link: \e[;32mhttps://namemc.com/profile/${UNFORMATTED}\e[0m\n" | |
printf "\n" | |
printf "\e[1;96mAvatar: \e[;32mhttps://minotar.net/avatar/${UNFORMATTED}.png\e[0m\n" | |
printf "\e[1;96mBody: \e[;32mhttps://minotar.net/armor/body/${UNFORMATTED}.png\e[0m\n" | |
printf "\e[1;96mSkin: \e[;32mhttps://minotar.net/skin/${UNFORMATTED}.png\e[0m\n" | |
else | |
printf "\e[1;91mNot a valid username or UUID!\e[0m\n" | |
exit 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment