TranslatableComponent reserialization throws an exception
datatags opened this issue ยท 1 comments
Describe the bug
When you unwrap a TranslatableComponent (ex. from /minecraft:give) and then re-wrap it, the server throws an exception
To Reproduce
Steps to reproduce the behavior:
- Compile the following code: (or demo plugin in a zip with source: Translatable_Component_Error_Example.zip )
package me.Datatags.TCEE;
import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.ComponentConverter;
import net.md_5.bungee.api.chat.BaseComponent;
public class TCEE extends JavaPlugin {
public void onEnable() {
ProtocolLibrary.getProtocolManager().addPacketListener(new TCEEListener(this));
}
public class TCEEListener extends PacketAdapter {
public TCEEListener(TCEE main) {
super(main, PacketType.Play.Server.CHAT);
}
@Override
public void onPacketSending(PacketEvent e) {
if (e.getPacket().getChatComponents().read(0) != null) {
BaseComponent[] component = ComponentConverter.fromWrapper(e.getPacket().getChatComponents().read(0));
e.getPacket().getChatComponents().write(0, ComponentConverter.fromBaseComponent(component));
}
}
}
}
- Start it in a test server along with ProtocolLib
- Run
/minecraft:give @a acacia_boat
- See the error in the console, despite the /give message packet still coming through.
Expected behavior
No errors to be thrown and the packet to be unchanged.
Version Info
https://pastebin.com/hZHSjCe3
Additional context
Error that is dumped to the console: https://pastebin.com/ibe6PSRn
If the error is not with ProtocolLib, sorry, don't really know how to tell, and if you know where the problem is coming from that would be awesome.
Thanks for your time!
Edit: related thread at https://www.spigotmc.org/threads/451862/