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

Improve MOTD simplifies #638

Merged
merged 2 commits into from
Sep 20, 2023
Merged

Improve MOTD simplifies #638

merged 2 commits into from
Sep 20, 2023

Conversation

PerchunPak
Copy link
Member

They handle now 3 more scenarios:

  • Meaningless resets and colors (&a1&a2 -> &a12)
  • Nearby strings (["123", "456"] -> ["123456"])
  • Spaces between duplicated formattings/colors (&a &a1 -> &a 1)

I also added a test which ensures that we don't remove strings that are only spaces (because I had such an idea in TODO, but then realized that spaces can be used as delimiters).

Example

Unedited MOTD from our Discord chat:

§r                  §r§l§r§l§aS§r§l§aE§r§l§aR§r§l§aV§r§l§aE§r§l§aR§r §r§f| §r§7[1.19-19.2]§r
§r  §r§aW§r§ae§r§al§r§ac§r§ao§r§am§r§ae§r §r§at§r§ao§r §r§at§r§ah§r§ae§r §r§am§r§ao§r§as§r§at§r §r§af§r§au§r§an§r §r§aa§r§an§r§ad§r §r§ad§r§ae§r§ad§r§ai§r§ac§r§aa§r§at§r§ae§r§ad§r §r§ac§r§ao§r§am§r§am§r§au§r§an§r§ai§r§at§r§ey§r§e!§r

is now transformed into

                  §aSERVER §f| §7[1.19-19.2]
  §aWelcome to the most fun and dedicated communit§ey!

but before was

§r                  §aS§aE§aR§aV§aE§aR§r §f| §7[1.19-19.2]§r
§r  §aW§ae§al§ac§ao§am§ae§r §at§ao§r §at§ah§ae§r §am§ao§as§at§r §af§au§an§r §aa§an§ad§r §ad§ae§ad§ai§ac§aa§at§ae§ad§r §ac§ao§am§am§au§an§ai§at§ey§e!

P.S. It may be a breaking change, because now it gives much less number of elements, than it was before. But it should be expected, and no public API was changed.

They handle now 3 more scenarios:
- Meaningless resets and colors (`&a1&a2` -> `&a12`)
- Nearby strings (`["123", "456"]` -> `["123456"]`)
- Spaces between duplicated formattings/colors (`&a &a1` -> `&a 1`)

I also added a test which ensures that we don't remove strings that are only spaces (because I had such an idea in TODO, but then realized that spaces can be used as delimiters).
@PerchunPak PerchunPak added type: enhancement Improvement to an existing feature area: API Related to core API of the project labels Sep 19, 2023
@PerchunPak
Copy link
Member Author

I think we accidentally created the most powerful Minecraft MOTD humanizer

Copy link
Member

@ItsDrike ItsDrike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

In a way yes, this is a breaking change, though I don't think we have to consider it as such, as I'd expect most people using simplify to only be using it for nice visual representation, rather than for storing the final result somewhere / testing against it / using it as some kind of key. Everyone should always use the actual motd as it was returned from the server for things like that.

However it might be a good idea to explain that these kinds of changes are permitted. We could add something like a version guarantees page in the docs, explaining what is and isn't considered a breaking change for us. As an example, this is the page I made for mcproto: https://mcproto.readthedocs.io/en/stable/pages/version_guarantees. But that's something for another PR.

@kevinkjt2000 kevinkjt2000 merged commit 9853c7a into master Sep 20, 2023
7 checks passed
@kevinkjt2000 kevinkjt2000 deleted the improve-motd-simplifies branch September 20, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Related to core API of the project type: enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants