Class PacketListenerManager

java.lang.Object
net.minestom.server.listener.manager.PacketListenerManager

public final class PacketListenerManager extends Object
  • Constructor Details

    • PacketListenerManager

      public PacketListenerManager()
  • Method Details

    • processClientPacket

      public <T extends ClientPacket> void processClientPacket(T packet, PlayerConnection connection, ConnectionState state)
      Processes a packet by getting its PacketPlayListenerConsumer and calling all the packet listeners.
      Type Parameters:
      T - the packet type
      Parameters:
      packet - the received packet
      connection - 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 packet
      packetClass - the class of the packet
      consumer - 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 packet
      consumer - 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 packet
      consumer - the new packet's listener