Closed sakurawald closed 1 month ago
However, the placeholder
can injected into hover
tag
<hover:'/msg %player:name%'>hover me</hover>
Hey! what version and which mods do you have this issues with?
Hey! what version and which mods do you have this issues with?
It's
modImplementation(include("eu.pb4:placeholder-api:${project.placeholder_api_version}"))
placeholder_api_version=2.4.0+1.21
The parser and context is
private static final MergedParser MERGED_PARSER = new MergedParser(
new NodeParser[]{
DEFAULT_PLACEHOLDER_PARSER
, TagParser.QUICK_TEXT_WITH_STF
});
public static @NotNull Component ofComponent(@Nullable Audience audience, boolean isKey, String keyOrString, Object... args) {
String string = isKey ? getString(audience, keyOrString, args) : keyOrString;
PlaceholderContext placeholderContext;
if (audience instanceof PlayerEntity playerEntity) {
placeholderContext = PlaceholderContext.of(playerEntity);
} else {
placeholderContext = PlaceholderContext.of(Fuji.SERVER);
}
ParserContext parserContext = ParserContext.of(PlaceholderContext.KEY, placeholderContext);
return MERGED_PARSER.parseText(TextNode.of(string), parserContext).asComponent();
}
The full code is inside my MessageUtil
: https://github.com/sakurawald/fuji-fabric/blob/dev/src/main/java/io/github/sakurawald/util/MessageUtil.java
Oh yeah, you need to swap parsers around, through in this case you should use NodeParser.builder()
s it provides you everything and is more stable
Oh yeah, you need to swap parsers around, through in this case you should use
NodeParser.builder()
s it provides you everything and is more stable
I try this
private static final NodeParser MERGED_PARSER = ParserBuilder.of()
.add(DEFAULT_PLACEHOLDER_PARSER)
.add(TagParser.QUICK_TEXT_WITH_STF).build();
and
private static final NodeParser MERGED_PARSER = NodeParser.builder()
.add(DEFAULT_PLACEHOLDER_PARSER)
.add(TagParser.QUICK_TEXT_WITH_STF).build();
It's the same. Do i use the api wrong?
Yeah both are equal, it doesn't matter
private static final NodeParser MERGED_PARSER = NodeParser.builder()
.simplifiedTextFormat()
.globalPlaceholders()
.build();
I don't understand, the placeholder
can injected into the hover
tag, but the click:command_suggest
not work.
Do it doesn't work, will check as it might be a bug
Do it doesn't work, will check as it might be a bug
Yeah, it still doesn't work.
This issue addressed since v2.4.1+1.21
, thanks for you great work. <3
I want to write a format so that: one clich the text, it will suggests the
/msg <sender_player>
command.Case1
So, i write down the format:
But if corrupted in char![image](https://github.com/user-attachments/assets/9f5b7b7e-bce8-4717-a2eb-1013c293049b)
:
Case2
And if you wrap the
command_suggest
value with'
char. e.g.You will get![image](https://github.com/user-attachments/assets/254e4896-bd46-49d9-9ad2-68ef2b9a5327)
In case2, the parser seems to treat the
string literal
and skip the placeholder resolve. So i want to know if there is somestring interpolation
or someescape
that can supportcomplex nested tags