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(@NotNull T packet, @NotNull @NotNull PlayerConnection connection)
      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(@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 packet
      packetClass - the class of the packet
      consumer - 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 packet
      consumer - 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 packet
      consumer - the new packet's listener