Class PacketListenerManager
java.lang.Object
net.minestom.server.listener.manager.PacketListenerManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T extends ClientPacket>
voidprocessClientPacket
(T packet, @NotNull PlayerConnection connection) Processes a packet by getting itsPacketPlayListenerConsumer
and calling all the packet listeners.<T extends ClientPacket>
voidsetConfigurationListener
(@NotNull Class<T> packetClass, @NotNull PacketPlayListenerConsumer<T> consumer) <T extends ClientPacket>
voidsetListener
(@NotNull Class<T> packetClass, @NotNull PacketPlayListenerConsumer<T> consumer) Deprecated.<T extends ClientPacket>
voidsetListener
(@NotNull ConnectionState state, @NotNull Class<T> packetClass, @NotNull PacketPrePlayListenerConsumer<T> consumer) Sets the listener of a packet.<T extends ClientPacket>
voidsetPlayListener
(@NotNull Class<T> packetClass, @NotNull PacketPlayListenerConsumer<T> consumer) Sets the listener of a packet.
-
Constructor Details
-
PacketListenerManager
public PacketListenerManager()
-
-
Method Details
-
processClientPacket
public <T extends ClientPacket> void processClientPacket(@NotNull T packet, @NotNull @NotNull PlayerConnection connection) Processes a packet by getting itsPacketPlayListenerConsumer
and 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(@NotNull @NotNull ConnectionState state, @NotNull @NotNull Class<T> packetClass, @NotNull @NotNull 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(@NotNull @NotNull Class<T> packetClass, @NotNull @NotNull 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(@NotNull @NotNull Class<T> packetClass, @NotNull @NotNull PacketPlayListenerConsumer<T> consumer) -
setListener
@Deprecated public <T extends ClientPacket> void setListener(@NotNull @NotNull Class<T> packetClass, @NotNull @NotNull 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
-