papermc-473 BaseComponent
Wolf2323 opened this issue ยท 11 comments
Describe the bug
Since papermc-473 (the Adventure API update) some code of BetonQuest does not work anymore.
To Reproduce
Steps to reproduce the behavior:
- Write code like the following
public void onPacketSending(final PacketEvent event) {
if (event.getPlayer() != player) {
return;
}
if (event.getPacketType().equals(PacketType.Play.Server.CHAT)) {
final PacketContainer packet = event.getPacket();
final BaseComponent[] components = (BaseComponent[]) packet.getModifier().read(1);
- Now components are
null
since papermc-473
Expected behavior
An Array of BaseComponent (not null)
Version Info
https://pastebin.com/yjq284kF
Additional context
Link to source code: https://github.com/BetonQuest/BetonQuest/blob/master/src/main/java/org/betonquest/betonquest/compatibility/protocollib/conversation/PacketInterceptor.java#L60
It was so hard to find that out. I could not find the issue directly and searched it for 3 days
Unfortunately there's not a ton we can do about that ProtocolLib-side. packet.getModifier().read(...)
returns the raw packet contents. Plugins will have to update accordingly
@dmulloy2 I am too experiencing this. This is the toString representation of the getPacket() method, seems Paper has changed some things on their end with their "library":
PacketContainer[type=CHAT[class=PacketPlayOutChat, id=14], structureModifier=StructureModifier[fieldType=class java.lang.Object, data=[private net.minecraft.server.v1_16_R3.IChatBaseComponent net.minecraft.server.v1_16_R3.PacketPlayOutChat.a, public net.kyori.adventure.text.Component net.minecraft.server.v1_16_R3.PacketPlayOutChat.adventure$message, public net.md_5.bungee.api.chat.BaseComponent[] net.minecraft.server.v1_16_R3.PacketPlayOutChat.components, private net.minecraft.server.v1_16_R3.ChatMessageType net.minecraft.server.v1_16_R3.PacketPlayOutChat.b, private java.util.UUID net.minecraft.server.v1_16_R3.PacketPlayOutChat.c]]]
Sorry can you please be more specific? I also have thousands of users on 1.8.8 so that would mean we have to support two systems, can you please provide a sample of upgrading code for us?
Sorry can you please be more specific? I also have thousands of users on 1.8.8 so that would mean we have to support two systems, can you please provide a sample of upgrading code for us?
I hear there are some learning platforms, academies if you will, for discovering how to solve such problems. Ones that let you become self-reliant and self-sufficient and understand Bukkit / Spigot / BungeeCord.
If you want a slightly less fragile hack without completely changing your system, send the messages that should go through with ProtocolLib as well and use the PacketContainer's meta / create your own cache checking against the container instead of an arbitrary legacy string with code against arbitrary CB/Spigot/Paper implementation... with 1.16, you could also just use the sender uuid, but ๐คทโโ๏ธ
Only to help everyone that ran into the same problem.
The package has the following format on Spigot:
0: IChatBaseComponent
1: BaseComponent[]
2: ChatMessageType
3: UUID
And the following format on Paper:
0: IChatBaseComponent
1: Component (From Adventure API)
2: BaseComponent[]
3: ChatMessageType
4: UUID
As you can see a new field with the index 1 has been introduced and the other fields are now increased by one.
So now you need to handle this by your own, in your code.
Sorry can you please be more specific? I also have thousands of users on 1.8.8 so that would mean we have to support two systems, can you please provide a sample of upgrading code for us?
I hear there are some learning platforms, academies if you will, for discovering how to solve such problems. Ones that let you become self-reliant and self-sufficient and understand Bukkit / Spigot / BungeeCord.
Thanks, I heard this course is getting accredited by Mojang soon and will celebrate this great news with you guys
Sorry can you please be more specific? I also have thousands of users on 1.8.8 so that would mean we have to support two systems, can you please provide a sample of upgrading code for us?
I hear there are some learning platforms, academies if you will, for discovering how to solve such problems. Ones that let you become self-reliant and self-sufficient and understand Bukkit / Spigot / BungeeCord.
Thanks, I heard this course is getting accredited by Mojang soon and will celebrate this great news with you guys
Sounds like nonsense to me, can you quote the Mojang verification on this? I asked around today and they have no clue who you are. If you are "accredited", then I wish you (and Mojang!!) the best of luck.