Class PacketTypeListenerSet

java.lang.Object
com.comphenix.protocol.concurrent.PacketTypeListenerSet

public class PacketTypeListenerSet extends Object
Manages the association between packet types and their corresponding listeners.

This class is thread-safe for modifications. All read methods work on a lock-free, best-effort principle, ensuring fast access.

  • Constructor Details

    • PacketTypeListenerSet

      public PacketTypeListenerSet()
  • Method Details

    • add

      public boolean add(PacketType packetType, PacketListener listener)
      Adds a listener for a specific packet type.
      Parameters:
      packetType - the packet type
      listener - the listener to add
      Returns:
      true if the listener and packetType was added to the set; false otherwise
      Throws:
      NullPointerException - if the packetType or listener is null
    • remove

      public boolean remove(PacketType packetType, PacketListener listener)
      Removes a listener for a specific packet type.
      Parameters:
      packetType - the packet type
      listener - the listener to remove
      Returns:
      true if the set contained the specified listener; false otherwise
      Throws:
      NullPointerException - if the packetType or listener is null
    • contains

      public boolean contains(PacketType packetType)
      Checks if there are any listeners for a specific packet type.
      Parameters:
      packetType - the packet type
      Returns:
      true if there are listeners for the packet type, false otherwise
    • contains

      public boolean contains(Class<?> packetClass)
      Checks if there are any listeners for a specific packet class.
      Parameters:
      packetClass - the packet class
      Returns:
      true if there are listeners for the packet class, false otherwise
    • values

      public com.google.common.collect.ImmutableSet<PacketType> values()
      Gets all the packet types that have listeners.
      Returns:
      a set of packet types that have listeners
    • clear

      public void clear()
      Clears all listeners and their associated packet types.