Class PacketListenerManager

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

public final class PacketListenerManager extends Object
  • Field Details

    • LOGGER

      public static final org.slf4j.Logger LOGGER
  • Constructor Details

    • PacketListenerManager

      public PacketListenerManager(ServerProcess serverProcess)
  • Method Details

    • processClientPacket

      public <T extends ClientPacket> void processClientPacket(@NotNull T packet, @NotNull @NotNull Player player)
      Processes a packet by getting its PacketListenerConsumer and calling all the packet listeners.
      Type Parameters:
      T - the packet type
      Parameters:
      packet - the received packet
      player - the player who sent the packet
    • setListener

      public <T extends ClientPacket> void setListener(@NotNull @NotNull Class<T> packetClass, @NotNull @NotNull PacketListenerConsumer<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