Phoenix616 / MineDown

A MarkDown inspired markup library for Minecraft chat components
https://wiki.phoenix616.dev/library/minedown/
MIT License
296 stars 21 forks source link

Replacements are broken by colour code gradients. #13

Closed Xemorr closed 3 years ago

Xemorr commented 3 years ago

Used Version

1.7.0-SNAPSHOT

Environment description

Windows 10 Java 11

What is happening?

"&e&lClass &8&l»&#ff0-#fff& %gifter% &7has blessed you with extra hearts!" The %gifter% isn't replaced when there is a gradient across it.

What did you expect to happen?

I expected the %gifter% to be replaced by whatever I specify in my program

Additional context

Phoenix616 commented 3 years ago

You will have to use the replaceFirst option on the MineDown class in order for replacements to be applied before parsing. Afterwards it will not work and most likely never will as it would be impossible to apply gradients first and the replace placeholders without the gradient "desyncing".

Unfortunately changing the default behaviour of the parse utility method now is also out of the question as plugins will rely on it being replaced after the formatting was applied, not before.

Xemorr commented 3 years ago

Is there a way you can change it to replaceFirst(true) by default in your own plugin?

Phoenix616 commented 3 years ago

Currently not, no. But providing some way to do that (e.g. via a system property) would be an interesting solution for this.

Xemorr commented 3 years ago

Okay, thank you!