Closed Elikill58 closed 6 days ago
I cannot replicate this whatsoever, neither on latest 1.20.4 nor on 1.21. Are you using the vanilla client?
Yes, vanilla without mods. You mean, the line with the formatting is well showing the hover content ?
Note: maybe it need some formatting, as I personally change the format of the message, but idk if it's important
yea, this is how it looks on my end.
Ok, nevermind, it's only when we change the formatting as this for example:
@EventHandler(priority = EventPriority.LOWEST)
public void onChatLow(AsyncPlayerChatEvent e) {
e.setFormat("%1$s: %2$s");
}
// then the paper event
@EventHandler
public void onChat(AsyncChatEvent e) {
e.message(e.message().hoverEvent(HoverEvent.showText(Component.text("This is a test"))));
}
Because you're using the legacy formatting stuff, which causes us to have to have to populate that renderer format which only supports legacy text in order to retain behavior. You can't miss modern and legacy and expect modern features to work, use the ChatRenderer API
The problem is, in my specific case, it's changed by others plugins. So, I don't know when it will be fine or not. Also, event by using this:
for(Audience a : e.viewers().isEmpty() ? Bukkit.getOnlinePlayers() : e.viewers())
a.sendMessage(e.renderer().render(p, p.displayName(), message, a));
e.setCancelled(true);
Or this:
e.message(e.renderer().render(p, p.displayName(), message, p));
The issue is still the same (so even by using chat renderer)
That's not how you use the renderer, you're supposed to implement your own renderer and set it via the setter
Once again, the issue here is that the ChatRenderer is a legacy chat render, which does not understand modern text formatting, calling it manually is not going to change that
there is no good solution here which doesn't involve you replacing the chat renderer with something able to actually use components, the only caveat here is that you will induce some behavioral changes as legacy and modern text work differently
Ok, and so, I could fix it by making my own chat renderer that would convert from legacy to modern ?
Do you think it's possible to make a PR to fix it for everyone ? Or change the legacy one (with PR)?
Yes
No, because legacy works different to components, i.e. bleedthrough, you'd just break chat formatting plugin behavior
Expected behavior
I want to add hover content when player send message in chat. So, I change the message value from
AsyncChatEvent
event.Observed/Actual behavior
The message is well edited, but there is no hover or click event. If I send the message myself, the hover is well sent
Steps/models to reproduce
Plugin and Datapack List
My plugin test
Paper version
This server is running Paper version git-Paper-497 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: d8d54d9 on ver/1.20.4) You are running the latest version Previous version: git-Paper-496 (MC: 1.20.4)
Other
No response