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

API for "caching" MiniMessage strings (or other serializer specific data) for ease of sending #1065

Open
kezz opened this issue Apr 16, 2024 · 0 comments

Comments

@kezz
Copy link
Member

kezz commented Apr 16, 2024

Related to #848, there seems to be some desire to remove the common usage of audience.sendMessage(MiniMessage.miniMessage().deserialize("my string")) in favour of a shorthand method for this. The MiniMessageAudience proposed in that PR is nice, but fails to be generic enough to be useful.

I think providing a wrapper for ComponentLike that accepts a serializer and the data to be serialized (open for extensions such as additional MiniMessage tag resolvers or context objects) would be quite nice, allowing for a replacement of the common pattern above:

// Stored centrally somewhere.
public static MiniMessageString myMiniMessageString = MiniMessage.miniMessage().createString("my string", tagResolvers);

// Sent at a later date (optionally adding additional context).
player.sendMessage(myMiniMessageString);
player.sendMessage(myMiniMessageString.withContext(player).withExtraTags(additionalTags));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant