Better adventure api integration
GliczDev opened this issue ยท 3 comments
Describe the bug
Chat packet fields are null when message has sender (i mean sender isn't new UUID(0, 0)
)
To Reproduce
Steps to reproduce the behavior:
- Register
PacketType.Play.Server.CHAT
listener - Try to get chat component
- See error
Expected behavior
Chat packet fields should contains basecomponent with message
Version Info
ProtocolLib Version: ProtocolLib v5.0.0-SNAPSHOT-b569
Bukkit Version: 1.18.2-R0.1-SNAPSHOT
Server Version: git-Paper-220 (MC: 1.18.2)
Java Version: 17.0.1
If you're using paper then sometimes the component field is no longer set in favor of an adventure component field, for example:
final ClientboundChatPacket packet = new ClientboundChatPacket(/* message component */ null, ...); packet.adventure$message = message; this.getHandle().connection.send(packet);
Okay, so how can get it and convert it to basecomponent?
If you're using paper then sometimes the component field is no longer set in favor of an adventure component field, for example:
final ClientboundChatPacket packet = new ClientboundChatPacket(/* message component */ null, ...);
packet.adventure$message = message;
this.getHandle().connection.send(packet);
So there is currently no direct modifier available for this. You can use event.getPacket().getModifier().withType(Component.class).read(0)
. If you want to convert it into a WrappedChatComponent, you can use AdventureComponentConverter.fromComponent
.
If you don't mind, please change the title to something like "Better adventure api integration", so that I remember looking at what we should support to make it easier accessible. Thanks :)