Interface PacketEvent

All Known Subinterfaces:
PacketReceiveEvent, PacketSendEvent

@DispatchScoped @NettySafe public interface PacketEvent
Dispatch-scoped generic native packet event. All access throws IllegalStateException after listener dispatch ends.
  • Method Details

    • connection

      ConnectionHandle connection()
      Returns the connection handle.
      Returns:
      connection handle
    • direction

      PacketDirection direction()
      Returns the packet direction.
      Returns:
      packet direction
    • phase

      ProtocolPhase phase()
      Returns the protocol phase.
      Returns:
      protocol phase
    • type

      PacketType<?> type()
      Returns the stable semantic packet type.
      Returns:
      stable semantic packet type
    • nativePacket

      Object nativePacket()
      Returns the current logical native packet.
      Returns:
      current logical native packet
    • view

      <V extends PacketView> V view(Class<V> viewType)
      Creates or returns the dispatch-local typed view.
      Type Parameters:
      V - requested view type
      Parameters:
      viewType - requested view class
      Returns:
      compatible cached view
    • isViewCreated

      boolean isViewCreated()
      Reports whether a typed view was created.
      Returns:
      whether a typed view was created
    • isCancelled

      boolean isCancelled()
      Reports whether dispatch currently cancels the packet.
      Returns:
      whether dispatch currently cancels the packet
    • setCancelled

      void setCancelled(boolean cancelled)
      Changes cancellation state visible to later listeners.
      Parameters:
      cancelled - new cancellation state
    • cancel

      default void cancel()
      Cancels the packet.
    • replaceNativePacket

      void replaceNativePacket(Object nativePacket)
      Replaces the current logical native packet after adapter validation.
      Parameters:
      nativePacket - replacement packet
    • sync

      void sync(SynchronizedPacketListener listener)
      Suspends this packet and continues the current listener on the connection player's entity scheduler. The callback may inspect Bukkit state and edit this packet before dispatch resumes on Netty.
      Parameters:
      listener - synchronized continuation
    • syncAt

      void syncAt(Object platformLocation, SynchronizedPacketListener listener)
      Suspends this packet and continues the current listener on the supplied Bukkit location's region.
      Parameters:
      platformLocation - Bukkit Location
      listener - synchronized continuation