aadnk / ProtocolLib

Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
288 stars 92 forks source link

Empty Packet Error Under BungeeCord #172

Open DefinitlyEvil opened 4 years ago

DefinitlyEvil commented 4 years ago

Make sure you've done the following:

I'm sorry but I'm not sure whether it's a BungeeCord problem or ProtocolLib problem, I tried to debug with my own code I couldn't find any problem.

Timings:

=== PLUGIN GUIControlsAPI ===
 TYPE: SYNC_SERVER_SIDE 
 -------------------------------------------------------------------------------------------------------------------------------------------
 Protocol:      Name:                         ID:                 Count:       Min (ms):       Max (ms):       Mean (ms):      Std (ms): 
 -------------------------------------------------------------------------------------------------------------------------------------------
 PLAY            CLOSE_WINDOW                  20 (Legacy: 255)    7            0.006083        0.218845        0.045829        0.079619 
 PLAY            WINDOW_ITEMS                  21 (Legacy: 255)    19           0.001918        0.016176        0.006395        0.003082 
 PLAY            SET_SLOT                      23 (Legacy: 255)    377          0.001143        0.012852        0.002263        0.001379 
 PLAY            OPEN_WINDOW                   47 (Legacy: 255)    8            0.002191        0.683816        0.089183        0.240274 
 SUM             -                             -                   411          0.001143        0.683816        0.004888        0.035416 
 => Time on main thread: 2.008788 ms

Description and relevant errors:

The issue was caused by opening a custom Anvil inventory to the player. 
If without BungeeCord, the window can open without a problem. 
If with BungeeCord, the player will get kicked and moved to default server with debug message: 
<-> DownstreamBridge <-> [main] - corrupted frame: Empty Packet!

Code used to send the packet:

PacketContainer windowOpen = new PacketContainer(PacketType.Play.Server.OPEN_WINDOW);
windowOpen.getIntegers().write(0, fakeWindowId);
windowOpen.getStrings().write(0, "minecraft:anvil");
windowOpen.getChatComponents().write(0, WrappedChatComponent.fromText(title));
protocol.sendServerPacket(player, windowOpen);