Skip to content

Use MiniMessage#deserialize(String, Pointered) for send messages#12176

Closed
novitpw wants to merge 1 commit into
PaperMC:mainfrom
novitpw:main
Closed

Use MiniMessage#deserialize(String, Pointered) for send messages#12176
novitpw wants to merge 1 commit into
PaperMC:mainfrom
novitpw:main

Conversation

@novitpw
Copy link
Copy Markdown
Contributor

@novitpw novitpw commented Feb 24, 2025

This small change allows to use recent changes from Adventure 4.17.0. Passing Pointered to MiniMessage#deserialize(String, Pointered) method allows to take Pointered from MiniMessage context (net.kyori.adventure.text.minimessage.Context) using Context#target method.

Usage example:

static TagResolver DISPLAY_NAME_TAG_RESOLVER = TagResolver.resolver("display_name", new BiFunction<ArgumentQueue, Context, Tag>() { // without the use of lambda for clarity
            @Override
            public Tag apply(final ArgumentQueue argumentQueue, final Context context) {
                Audience target = context.targetAsType(Audience.class); // Or CommandSender, Player, etc.

                return Tag.inserting(target.get(Identity.DISPLAY_NAME).orElseThrow());
            }
        });

...

player.sendRichMessage("You display name is: <display_name>", DISPLAY_NAME_TAG_RESOLVER);

The simplest testing:
image
image

…Sender#sendRichMessage and Server#sendRichMessage for send messages
@novitpw novitpw requested a review from a team as a code owner February 24, 2025 21:00
@github-actions
Copy link
Copy Markdown

Please do not open pull requests from the main branch, create a new branch instead.

@github-actions github-actions Bot closed this Feb 24, 2025
@novitpw novitpw deleted the main branch February 24, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

1 participant