Skip to content
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

Closed
ldilley opened this issue Aug 8, 2021 · 8 comments
Closed

Accommodate extra field in MotD data returned in JSON responses #84

ldilley opened this issue Aug 8, 2021 · 8 comments
Assignees
Labels
new feature Request something new
Projects

Comments

@ldilley
Copy link
Member

ldilley commented Aug 8, 2021

@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/

@ldilley ldilley added the new feature Request something new label Aug 8, 2021
@ldilley ldilley added this to ToDo in MineStat via automation Aug 8, 2021
@isaackogan
Copy link

isaackogan commented Aug 9, 2021

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)

@mindsolve
Copy link
Collaborator

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?

@braulio-dev
Copy link

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.

mindsolve added a commit to mindsolve/minestat that referenced this issue Aug 9, 2021
@mindsolve
Copy link
Collaborator

mindsolve commented Aug 9, 2021

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 motd attribute doesn't change, only the 1.7 SLP one will be brought in line
  • 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:
grafik

I created a python draft version in my test-fork: https://github.com/mindsolve/minestat/tree/feature/python-proper-motd-parsing

@ldilley
Copy link
Member Author

ldilley commented Aug 10, 2021

The Python code in your fork looks good to me, @mindsolve. Thank you for your diligence!

@mindsolve
Copy link
Collaborator

mindsolve commented Aug 15, 2021

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# ✔️ (Merged PR #105) ✔️ (Merged PR #105)
Go ⛔ (No json SLP support)
Java ✔️ (Merged PR #89) ✔️ (Merged PR #89)
JavaScript ⛔ (No json SLP support)
PHP ✔️ (Merged PR #92) ✔️ (Merged PR #92)
Perl ⛔ (No json SLP support)
PowerShell ✔️ (Merged PR #104) ✔️ (Merged PR #104)
Python ✔️ (Merged PR #85) ✔️ (Merged PR #85)
Ruby ✔️ (Merged PR #91) ✔️ (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).

ldilley added a commit to ldilley/minestat that referenced this issue Sep 8, 2021
ldilley added a commit to ldilley/minestat that referenced this issue Sep 11, 2021
@ldilley
Copy link
Member Author

ldilley commented Sep 12, 2021

Note to fix Ruby implementation (match PHP changes per #93).

ldilley added a commit to ldilley/minestat that referenced this issue Sep 27, 2021
ldilley pushed a commit to ldilley/minestat that referenced this issue Jan 23, 2022
ldilley added a commit to ldilley/minestat that referenced this issue Jan 23, 2022
ldilley added a commit to ldilley/minestat that referenced this issue Jan 23, 2022
ldilley added a commit to ldilley/minestat that referenced this issue Jan 23, 2022
@ldilley
Copy link
Member Author

ldilley commented Jan 12, 2023

I am considering this issue resolved. The Go, JavaScript, and Perl subprojects will be handled at a later time.

@ldilley ldilley closed this as completed Jan 12, 2023
MineStat automation moved this from In Progress to Complete Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Request something new
Projects
MineStat
Complete
Development

No branches or pull requests

4 participants