Skip to content

Add a JSON output mode #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MarkusTieger opened this issue Nov 5, 2024 · 3 comments · Fixed by #100
Closed

Add a JSON output mode #99

MarkusTieger opened this issue Nov 5, 2024 · 3 comments · Fixed by #100
Labels
enhancement New feature or request

Comments

@MarkusTieger
Copy link

Add an "--json" option. This will then print the status as json, instead of

mc.hypixel.net:25565 : version=Requires MC 1.8 / 1.21 online=33020 max=200000 motd='                §aHypixel Network §c[1.8-1.21]
   §e§lNEW BUILD BATTLE MODE§7§l: §6§lSPEED BUILDERS'

Like this:

{
  "host": "mc.hypixel.net",
  "port": 25565",
  "version": "Requires MC 1.8 / 1.21",
  "online": 33020,
  "max": 200000,
  "motd": "                §aHypixel Network §c[1.8-1.21]\n   §e§lNEW BUILD BATTLE MODE§7§l: §6§lSPEED BUILDERS"
}

Why?
The current format can't be safely parsed afaik.
The motd could just escape the ' boundries, or the version could contain a "online=", which would destroy any regex.

@itzg
Copy link
Owner

itzg commented Nov 6, 2024

Great idea and should be easy to implement.

@itzg itzg added the enhancement New feature or request label Nov 6, 2024
@itzg
Copy link
Owner

itzg commented Nov 11, 2024

Since the retrieved server info is already structured for json, I'll have it output that as sub-field like:

{"host":"localhost","port":25565,"server_info":{"version":{"name":"1.21.3","protocol":768},"players":{"max":20,"online":0,"Sample":null},"description":{"text":"A Minecraft Server","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"","extra":null},"favicon":""}}

@itzg
Copy link
Owner

itzg commented Nov 11, 2024

Released in https://github.com/itzg/mc-monitor/releases/tag/0.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants