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
Accommodate extra field in MotD data returned in JSON responses #84
Comments
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! |
Hello @mindsolve, |
After some discussion in the discord channel, we came to the following solution:
See the following examples: 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~~' 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:
* Edit by @mindsolve: 2021-09-05: PR for Java has been merged (#89). |
Related to FragLand#84.
Note to fix Ruby implementation (match PHP changes per #93). |
Related to FragLand#84.
Related to FragLand#84.
Related to FragLand#84.
I am considering this issue resolved. The Go, JavaScript, and Perl subprojects will be handled at a later time. |
@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 thedescription
object of JSON responses. An example is below:Notice how the
text
field of thedescription
object is actually empty. MineStat is working as intended in this regard. However, theextra
data is not currently processed at all. @mindsolve proposed stripping the formatting characters out of the response and displaying the plain/unformatted text. Additionally, theextra
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/
The text was updated successfully, but these errors were encountered: