ProtocolLib

3M Downloads

CLIENT_COMMAND packet doesn't work correctly (player inventory open packet)

pawelkuwa opened this issue ยท 2 comments

commented

Make sure you're doing the following

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

Describe the question
I want to do code when player open inventory with E button.

API method(s) used
Using maven.
image

Expected behavior
I want to do code when player open inventory with E button.

Code

    public testClick() {
        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
        manager.addPacketListener(new PacketAdapter(MCPPlayer.getPlugin(), ListenerPriority.NORMAL, PacketType.Play.Client.CLIENT_COMMAND) {
            @Override
            public void onPacketReceiving(PacketEvent e) {
                Player player = e.getPlayer();
                PacketContainer packet = e.getPacket();
                EnumWrappers.ClientCommand action = packet.getClientCommands().read(0);
                if (action == EnumWrappers.ClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
                    player.sendMessage("ta");
                }
            }
        });
    }

Additional context
I read on spigot forum that Client_command packet can read when player open his inventory with E button. Other packet like CHAT works correctly, but when i want to fire code after Client_Command packet code doesn't work.

commented

CLIENT_COMMAND is not the correct packet, you're listening to opening the stats menu. There is no packet send to the server when opening the local player inventory.

commented

then which packet are fired when player open his inventory? i see that server do that when player open his workbench was filled with items