LogoLogo
LogoLogo
  • What is PacketEvents?
  • Prerequisites
  • Getting Started
  • The PacketEvents Instance
  • Creating Your PacketEvents Instance
    • (Optional) Configuring PacketEvents
  • What is a PacketEvents Listener
  • Creating Your First Listener
  • Registering a Packet Listener
  • Sending and Simulating Packets
  • Advanced PacketEvents Example: Combining our Knowledge
  • FAQ (WIP)
Powered by GitBook
On this page
  • Packet Listener
  • Listener Priorities

Was this helpful?

What is a PacketEvents Listener

Packet listeners are used to process (or modify) incoming and outgoing information.

Previous(Optional) Configuring PacketEventsNextCreating Your First Listener

Last updated 5 months ago

Was this helpful?

Packet Listener

The packet listener is a feature provided by PacketEvents to read, modify, cancel, and delay packets. All packets in the game invoke the packet listener. Moreover, PacketEvents offers the PacketType registry, which allows you to detect what kind of packet is being sent or received. Once you have detected your desired packet, you may utilize our wrappers for reading and/or modification.

Furthermore, if you wish to modify a packet in your listener, simply using setters in your packet wrappers does not suffice. PacketEvents optimizes performance by only applying changes to the packet if you explicitly mark the event to be re-encoded.

Mark the event to be re-encoded whenever you apply changes to a packet.

Listener Priorities

You can register as many listeners as you want; hence, having some sort of order in PacketEvents is necessary. Just like the Bukkit API, PacketEvents allows you to assign priorities to your listeners. The LOWEST priority is the first to be invoked, while the MONITOR priority is the last to be invoked. The listener with the HIGHEST priority has the final say on the state of packets.

Valid priorities can be viewed .

Please avoid modifying packets in the MONITOR priority:

  • Only use this priority if you want to perform logic based on the outcome of the event.

If possible, pick the NORMAL priority:

  • This allows other projects to easily overturn your decisions.

here