Class PacketListenerManager
java.lang.Object
net.minestom.server.listener.manager.PacketListenerManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends ClientPacket>
voidprocessClientPacket(T packet, PlayerConnection connection) Processes a packet by getting itsPacketPlayListenerConsumerand calling all the packet listeners.<T extends ClientPacket>
voidsetConfigurationListener(Class<T> packetClass, PacketPlayListenerConsumer<T> consumer) <T extends ClientPacket>
voidsetListener(Class<T> packetClass, PacketPlayListenerConsumer<T> consumer) Deprecated.<T extends ClientPacket>
voidsetListener(ConnectionState state, Class<T> packetClass, PacketPrePlayListenerConsumer<T> consumer) Sets the listener of a packet.<T extends ClientPacket>
voidsetPlayListener(Class<T> packetClass, PacketPlayListenerConsumer<T> consumer) Sets the listener of a packet.
-
Constructor Details
-
PacketListenerManager
public PacketListenerManager()
-
-
Method Details
-
processClientPacket
Processes a packet by getting itsPacketPlayListenerConsumerand calling all the packet listeners.- Type Parameters:
T- the packet type- Parameters:
packet- the received packetconnection- the connection of the player who sent the packet
-
setListener
public <T extends ClientPacket> void setListener(ConnectionState state, Class<T> packetClass, PacketPrePlayListenerConsumer<T> consumer) Sets the listener of a packet.WARNING: this will overwrite the default minestom listener, this is not reversible.
- Type Parameters:
T- the type of the packet- Parameters:
state- the state of the packetpacketClass- the class of the packetconsumer- the new packet's listener
-
setPlayListener
public <T extends ClientPacket> void setPlayListener(Class<T> packetClass, PacketPlayListenerConsumer<T> consumer) Sets the listener of a packet.WARNING: this will overwrite the default minestom listener, this is not reversible.
- Type Parameters:
T- the type of the packet- Parameters:
packetClass- the class of the packetconsumer- the new packet's listener
-
setConfigurationListener
public <T extends ClientPacket> void setConfigurationListener(Class<T> packetClass, PacketPlayListenerConsumer<T> consumer) -
setListener
@Deprecated public <T extends ClientPacket> void setListener(Class<T> packetClass, PacketPlayListenerConsumer<T> consumer) Deprecated.Sets the listener of a packet.WARNING: this will overwrite the default minestom listener, this is not reversible.
- Type Parameters:
T- the type of the packet- Parameters:
packetClass- the class of the packetconsumer- the new packet's listener
-