Due to a Spigot change, in 1.14.x and later versions you have to use these methods instead of the classic ones:
Code (Java):
PacketEventManager.
registerSendListener(event
->{ Object packet
= event.
getPacket(); // The old packet class must remain the same as the new one event.
setPacket(newPacket
); Player player
= event.
getPlayer(); String packetName
= event.
getPacketName(); Object value
= event.
getValue("fieldName"); event.
setValue("fieldName", value
); event.
setCancelled(true); });
PacketEventManager.
registerRetriveListener(event
->{ Object packet
= event.
getPacket(); // The old packet class must remain the same as the new one event.
setPacket(newPacket
); Player player
= event.
getPlayer(); String packetName
= event.
getPacketName(); Object value
= event.
getValue("fieldName"); event.
setValue("fieldName", value
); event.
setCancelled(true); });
If you are supporting versions before and after 1.14, you have to use both events (PacketSendEvent and PacketRetriveEvent) and PacketEventManager.