Class PacketTypeListenerSet
java.lang.Object
com.comphenix.protocol.concurrent.PacketTypeListenerSet
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(PacketType packetType, PacketListener listener) Adds a listener for a specific packet type.voidclear()Clears all listeners and their associated packet types.booleancontains(PacketType packetType) Checks if there are any listeners for a specific packet type.booleanChecks if there are any listeners for a specific packet class.booleanremove(PacketType packetType, PacketListener listener) Removes a listener for a specific packet type.com.google.common.collect.ImmutableSet<PacketType> values()Gets all the packet types that have listeners.
-
Constructor Details
-
PacketTypeListenerSet
public PacketTypeListenerSet()
-
-
Method Details
-
add
Adds a listener for a specific packet type.- Parameters:
packetType- the packet typelistener- the listener to add- Returns:
trueif the listener and packetType was added to the set;falseotherwise- Throws:
NullPointerException- if the packetType or listener is null
-
remove
Removes a listener for a specific packet type.- Parameters:
packetType- the packet typelistener- the listener to remove- Returns:
trueif the set contained the specified listener;falseotherwise- Throws:
NullPointerException- if the packetType or listener is null
-
contains
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
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
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.
-