Class NetworkChannelPacketReceiveEvent

java.lang.Object
eu.cloudnetservice.driver.event.Event
eu.cloudnetservice.driver.event.events.network.NetworkEvent
eu.cloudnetservice.driver.event.events.network.NetworkChannelPacketReceiveEvent
All Implemented Interfaces:
Cancelable

public final class NetworkChannelPacketReceiveEvent extends NetworkEvent implements Cancelable
An event fired always when a packet is received in a channel. Reads to the packet buffer will get reflected down the line.
Since:
4.0
  • Field Details

    • packet

      private final Packet packet
    • cancelled

      private boolean cancelled
  • Constructor Details

    • NetworkChannelPacketReceiveEvent

      public NetworkChannelPacketReceiveEvent(@NonNull @NonNull NetworkChannel channel, @NonNull @NonNull Packet packet)
      Creates a new instance of this network event.
      Parameters:
      channel - the channel which is associated with this event.
      packet - the packet which was received.
      Throws:
      NullPointerException - if the given channel or packet is null.
  • Method Details

    • packet

      @NonNull public @NonNull Packet packet()
      Get the packet which got send by the other network component.
      Returns:
      the packet which got send.
    • cancelled

      public boolean cancelled()
      Gets the cancellation state of the event. A cancelled event will stop the execution of the representing change in the system, but will be passed to all event listeners nevertheless.
      Specified by:
      cancelled in interface Cancelable
      Returns:
      true if this is cancelled, false otherwise.
    • cancelled

      public void cancelled(boolean cancelled)
      Marks this event as cancelled and stops the execution of the representing change in the system. The event will be passed to other event listeners down the line anyway.
      Specified by:
      cancelled in interface Cancelable
      Parameters:
      cancelled - true if this event should get marked as cancelled, false otherwise.