Class PacketListenerInvoker
java.lang.Object
com.comphenix.protocol.injector.netty.channel.PacketListenerInvoker
This class facilitates the invocation of methods on the current packet listener.
It attempts to execute the
send, read, and disconnect
methods and, upon failure (either due to the absence of the method or the packet
listener being of an incorrect type), it delegates the call to the network manager.
Supported packet listener types include CONFIGURATION and PLAY. If the packet listener does not match these types, or if the required method is missing, the operation falls back to similar methods available in the network manager.
It is important to note that this class does not handle exceptions internally. Instead, it propagates them to the caller. During the initialization phase, the class will throw an exception if the necessary methods in the network manager are not available, ensuring that these dependencies are addressed early in the runtime.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddisconnect(String reason) Disconnects the player using the current packet listener if available and valid; otherwise, falls back to the network manager.static voidvoidReads a packet directly using the network manager.voidSends a packet using the current packet listener if available and valid; otherwise, falls back to the network manager.
-
Method Details
-
ensureStaticInitializedWithoutError
public static void ensureStaticInitializedWithoutError() -
send
Sends a packet using the current packet listener if available and valid; otherwise, falls back to the network manager.- Parameters:
packet- The packet to be sent.
-
read
Reads a packet directly using the network manager.- Parameters:
packet- The packet to be read.
-
disconnect
Disconnects the player using the current packet listener if available and valid; otherwise, falls back to the network manager.- Parameters:
reason- The reason for the disconnection.
-