-
-
Notifications
You must be signed in to change notification settings - Fork 148
Open
Description
I'm unsure as to why this was done, but can be seen here:
https://github.com/KyoriPowered/adventure/blob/main/4/api/src/main/java/net/kyori/adventure/text/renderer/TranslatableComponentRenderer.java#L202
if (arg.value() instanceof Component && !(arg.value() instanceof VirtualComponent)) {
The second part of that if, means that virtual components get completely ignored when rendering translatable, making them unusable other than for their fallback.
These are some examples of what you'd expect code to result to:
Works and has correct behavior:
// Renders as "Hello Username" just fine
virtual(Player.class, p -> text("Hello " + p.getName())); Does not work, has incorrect behavior:
// Assume some.key=Greeting: {}
// Renders as "Greeting: " (no fallback defined), should be "Greeting: Hello Username"
translatable(some.key, virtual(Player.class, p -> text("Hello " + p.getName())));
// Renders as "Greeting: fallback" (a fallback is defined), should be "Greeting: Hello Username"
var rendererWithFallback = new VirtualComponentRenderer<Player> {
@Override
public ComponentLike apply(Player p) {
return text("Hello " + p.getName());
}
@Override
public String fallbackString() {
return "fallback";
}
}
translatable(some.key, virtual(Player.class, renderWithFallback);Reactions are currently unavailable