Skip to content

Instantly share code, notes, and snippets.

@relyks
Created June 28, 2020 00:11
Show Gist options
  • Save relyks/fc1b24c413954128abafb994e4eb5918 to your computer and use it in GitHub Desktop.
Save relyks/fc1b24c413954128abafb994e4eb5918 to your computer and use it in GitHub Desktop.
set server_ip "149.56.16.230"
set server_port "25602"
set players_by_username (http "https://api.mcsrvstat.us/2/$server_ip:$server_port" | jq '.players.list | join(" ")')
set players_list (string split ' ' (string trim --left --right --chars="\"" $players_by_username))
for player in $players_list
switch $player
case "samtherat6"
set --append players "Samrat"
case "Felandric"
set --append players "Aviv"
case "RickSanchez1"
set --append players "Me"
end
end
# echo $players
if test (count $players) -eq 1
set output $players[1]
else if test (count $players) -eq 2
set output $players[1] 'and' $players[2]
else
set first_group (string join ', ' $players[1..-2])
set output $first_group 'and' $players[-1]
end
echo $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment