Accommodate extra field in MotD data returned in JSON responses
@isaackogan and @rey-dev reported yesterday via Discord that the MotD appears empty after pinging certain servers (such as Mineplex). After investigating, it was determined that some servers are making use of formatting in their MotDs and this data is being returned in an extra array inside the description object of JSON responses. An example is below:
{"version":{"name":"BungeeCord 1.8.x-1.17.x","protocol":756},"players":{"max":526,"online":525},"description":{"extra":[{"color":"white","text":" "},{"bold":true,"strikethrough":true,"color":"aqua","text":" "},{"bold":true,"strikethrough":true,"color":"dark_gray","text":"[ "},{"color":"white","text":" "},{"bold":true,"color":"blue","text":"Mineplex"},{"color":"white","text":" "},{"bold":true,"color":"white","text":"Games"},{"color":"white","text":" "},{"bold":true,"strikethrough":true,"color":"dark_gray","text":" ]"},{"bold":true,"strikethrough":true,"color":"aqua","text":" "},{"color":"white","text":""}],"text":""}
Notice how the text field of the description object is actually empty. MineStat is working as intended in this regard. However, the extra data is not currently processed at all. @mindsolve proposed stripping the formatting characters out of the response and displaying the plain/unformatted text. Additionally, the extra data in JSON format can be provided so the end user would be able to process it however they choose. For more details regarding JSON and formatting in Minecraft, see the following links:
https://wiki.vg/Chat#Current_system_.28JSON_Chat.29
https://minecraft.fandom.com/wiki/Formatting_codes
https://pypi.org/project/jsontextmc/
Is it possible the raw payload could also be included through some alternate method/function, since the colour formatting can be important (e.x if you want to mimic or display the MOTD accurately to an end-user)
Hi @isaackogan! This sounds like a good idea. I would propose that a stripped motd is provided via the current properties/methods and then to add a new property for the raw motd content. Or do you think that would break too many existing library usages?
Hello @mindsolve, I think the best option here would be to possibly keep the way the current property works, but also add the ones you are suggesting in order to keep the consistency for those who currently use the library.
After some discussion in the discord channel, we came to the following solution:
- The existing motd should contain the unchanged server motd (it already does in all but the 1.7 SLP)
- This way, the behaviour of the
motdattribute doesn't change, only the 1.7 SLP one will be brought in line
- This way, the behaviour of the
- A new attribute should be added, which contains a "human-readable" motd, with all formatting stripped away
See the following examples: "JSON Chat" components / 1.7 SLP protocol:
ms.motd = '{"extra": [{"color": "gold", "text": "~~"}, {"text": " "}, {"bold": true, "color": "dark_aqua", "text": "M"}, {"bold": true, "color": "gray", "text": "A"}, {"bold": true, "color": "dark_green", "text": "G"}, {"bold": true, "color": "blue", "text": "I"}, {"bold": true, "color": "dark_red", "text": "C"}, {"text": "1.16 v3"}, {"color": "gold", "text": "~~"}], "text": ""}'
ms.stripped_motd = '~~ MAGIC1.16 v3~~'
Old formatting codes:
ms.motd = '§6~~§r §3§lM§7§lA§2§lG§9§lI§4§lC§r1.16 v3§6~~§r'
ms.stripped_motd = '~~ MAGIC1.16 v3~~'
Minecraft screenshot:

I created a python draft version in my test-fork: https://github.com/mindsolve/minestat/tree/feature/python-proper-motd-parsing
The Python code in your fork looks good to me, @mindsolve. Thank you for your diligence!
After my PR for Python has been merged, this is the status regarding the implementation: (I will try to keep this status up-to-date)
| Variant | Fixed json SLP motd |
New attribute stripped_motd |
|---|---|---|
| C# | :heavy_check_mark: (Merged PR #105) | :heavy_check_mark: (Merged PR #105) |
| Go | :no_entry: (No json SLP support) |
:x: |
| Java | :heavy_check_mark: (Merged PR FragLand/minestat#89) | :heavy_check_mark: (Merged PR FragLand/minestat#89) |
| JavaScript | :no_entry: (No json SLP support) |
:x: |
| PHP | :heavy_check_mark: (Merged PR #92) | :heavy_check_mark: (Merged PR #92) |
| Perl | :no_entry: (No json SLP support) |
:x: |
| PowerShell | ✔️ (Merged PR #104) | ✔️ (Merged PR #104) |
| Python | :heavy_check_mark: (Merged PR FragLand/minestat#85) | :heavy_check_mark: (Merged PR FragLand/minestat#85) |
| Ruby | :heavy_check_mark: (Merged PR #91) | :heavy_check_mark: (Merged PR #91) |
* Edit by @mindsolve: 2021-09-05: PR for Java has been merged (#89). * Edit by @ldilley: 2021-09-07: PR for Ruby has been merged (#91). * Edit by @ldilley: 2021-09-10: PR for PHP has been merged (#92). * Edit by @ldilley: 2022-07-07: PR for PowerShell has been merged (#104). * Edit by @ldilley: 2022-07-24: PR for C# has been merged (#105).
Note to fix Ruby implementation (match PHP changes per #93).
I am considering this issue resolved. The Go, JavaScript, and Perl subprojects will be handled at a later time.