akropolis icon indicating copy to clipboard operation
akropolis copied to clipboard

Adding MP support to TextUtil

Open TureBentzin opened this issue 9 months ago • 6 comments

With this PR I suggest adding basic MiniPlaceholder support to TextUtil. I implemented this trying to hopefully fit with your codestyle.

Feel free to request changes.

TureBentzin avatar Apr 08 '25 14:04 TureBentzin

Hi, sorry for reviewing it this late. I was going through the changes, which I think are well implemented, but I'd like to understand the reason behind this change.

As far as I can tell, we already use PlaceholderUtil wherever placeholders can be applied, so I’m curious about what this change improves or solves, as TextUtil is only used when placeholders shouldn't be applied.

Thanks in advance!

zetastormy avatar Jul 07 '25 17:07 zetastormy

I finally had time to come back to this project and take a brief look at the PR again.

As I already wrote in the title, this PR introduces Miniplaceholders (https://github.com/MiniPlaceholders/MiniPlaceholders) support to Akropolis.

This allows all Akropolis messages (messages.yml) to contain MiniPlaceholder placeholders. Specifically, all text that runs through the

public static Component parse(String message) {..}

and

public static Component parse(String message, TagResolver resolver) {..}

methods in TextUtil.java, where your MiniMessage deserialization happens, may now contain placeholders.

TureBentzin avatar Jul 29 '25 18:07 TureBentzin

Due to the time that has passed since I opend this PR, I would be willing to rebase this PR so it is based on your newest version instead of the old one. That would also allow changing the commit messages to fit your spec.

TureBentzin avatar Jul 29 '25 18:07 TureBentzin

I understand now, I didn't notice previously that the messages from messages.yml didn't have any kind of placeholder replaced. If you have the time to rebase this PR, I would be grateful. Thank you!

zetastormy avatar Jul 29 '25 21:07 zetastormy

I did the rebase earlier today. You changed the behavior of the replacements in commit a8a5b74 to use string replacements instead of converting between components and text. I propose using standard MiniMessage TagResolvers for this, because that is exactly what they are designed for.

I have marked this PR as a draft for now. As soon as I find time to test the changes, I will mark it as ready for review.

TureBentzin avatar Jul 30 '25 20:07 TureBentzin

Thank you! And you're right, I should probably use TagResolvers for that.

zetastormy avatar Jul 31 '25 14:07 zetastormy