Interface PacketListener

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PacketListener
Represents a listener for a specific packet. A packet listener can be registered through the packet listener registry on a per-network-component and a per-channel basis. Each packet listener gets called in the order the listener was registered, the first registered listener will be called first.
Since:
4.0
  • Method Details

    • handle

      void handle(@NonNull @NonNull NetworkChannel channel, @NonNull @NonNull Packet packet) throws Exception
      Handles the incoming packet. A packet handle should be release-safe and transactional to preserve the content of the packet for listeners which are following in the chain. If a packet listener is not doing that, it might lead to unexpected exceptions in other packet listener implementations for the same packet.
      Parameters:
      channel - the channel from which the original packet came.
      packet - the packet which was received.
      Throws:
      Exception - if any exception occurs during handling of the packet.
      NullPointerException - if either the given channel or packet is null.