CLIENT_COMMAND packet doesn't work correctly (player inventory open packet)
pawelkuwa opened this issue ยท 2 comments
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.
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.
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.