ProtocolLib icon indicating copy to clipboard operation
ProtocolLib copied to clipboard

ProtocolLib may cause breaking packet reordering

Open MrEAlderson opened this issue 1 year ago • 2 comments

  • [X] This issue is not solved in a development build

Describe the bug Spawning a player relies on its player info being sent before its spawn packet. If the client is told to spawn a player with missing player info, it won't spawn it at all. As a consequence and in case a listener for the PlayerInfo packet is added to ProtocolLib, the NPC will not spawn at all:

      ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(MBedwars.plugin, Server.PLAYER_INFO) {
        @Override
        public void onPacketSending(PacketEvent event) {
          
        }
      });

On the hand if listening to both packets, the NPC will spawn just fine:

      ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(MBedwars.plugin, Server.PLAYER_INFO, Server.NAMED_ENTITY_SPAWN) {
        @Override
        public void onPacketSending(PacketEvent event) {
          
        }
      });

To Reproduce Steps to reproduce the behavior: Have a plugin that spawns NPCs using packets with no delay between its PlayerInfo and NamedEntitySpawn packet. Add a listener to ProtocolLib for only the PlayerInfo packet.

Version Info https://pastebin.com/wJMZtrz1

Potentially related to https://github.com/dmulloy2/ProtocolLib/issues/2948

MrEAlderson avatar Dec 18 '24 17:12 MrEAlderson

Add ListenerOptions.ASYNC to adapter

Jpx3 avatar Dec 20 '24 14:12 Jpx3

Add ListenerOptions.ASYNC to adapter

You want me to locate and fix every plugin existing that is listening wrongfully to that packet?

MrEAlderson avatar Dec 20 '24 17:12 MrEAlderson