ProtocolLib icon indicating copy to clipboard operation
ProtocolLib copied to clipboard

index out of bounds with CUSTOM_PAYLOAD in 5.2.0

Open Qiu-Ling-T opened this issue 1 year ago • 1 comments

Make sure you're doing the following

  • [ x ] You're using the latest build for your server version
  • [ x ] This isn't an issue caused by another plugin
  • [ x ] You've checked for duplicate issues
  • [ x ] You didn't use /reload

Describe the question I face index out of bounds question in writing a packet.I create a PacketContainer with CUSTOM_PAYLOAD,when I start to write something in it, the error happend.The code are follow: `PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.CUSTOM_PAYLOAD);

    plugin.getLogger().info("Sending dialog packet to player: " + player.getName());
    plugin.getLogger().info(String.valueOf(packet.getStrings().size()));
    packet.getStrings().write(0, "qiuling:dialog_packet");
    plugin.getLogger().info("Sending dialog packet to player: " + player.getName());`

and the error logger like this: com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0 at com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49) ~[ProtocolLib.jar:?] at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:315) ~[ProtocolLib.jar:?] I print the packet.getStrings().size(), and its result is 0.I don't know why.And I want to know how to write a correctly code.

Qiu-Ling-T avatar Jun 16 '24 17:06 Qiu-Ling-T

What Minecraft version are you running? This error could be caused by an outdated version of ProtocolLib. Try downloading the latest build: here

ineanto avatar Jun 17 '24 12:06 ineanto

same issue in 5.3.0 & 5.4.0 dev

kotaru34 avatar May 03 '25 16:05 kotaru34