Class PulsePacketSendEvent

java.lang.Object
org.bukkit.event.Event
dev.pulsemc.pulse.api.events.network.PulsePacketSendEvent
All Implemented Interfaces:
Cancellable

public class PulsePacketSendEvent extends Event implements Cancellable
Triggered when a packet is about to be added to the Pulse buffer.

This event is called synchronously on the main thread before any optimization logic. You can use this event to modify the packet, cancel it, or force immediate sending.

  • Constructor Details

    • PulsePacketSendEvent

      public PulsePacketSendEvent(Player player, Object packet)
  • Method Details

    • getPlayer

      public Player getPlayer()
      Gets the player receiving this packet.
      Returns:
      the target player
    • getPacket

      public Object getPacket()
      Gets the raw packet being sent.
      Returns:
      the packet
    • setPacket

      public void setPacket(Object packet)
      Replaces the packet with a modified one.
      Parameters:
      packet - the new packet
    • setCanBeOptimized

      public void setCanBeOptimized(boolean can)
      Sets whether this packet can be optimized by the engine.
      Parameters:
      can - true to allow optimization, false to force individual sending.
    • canBeOptimized

      public boolean canBeOptimized()
      Checks if this packet is allowed to be optimized.
      Returns:
      true if optimization is allowed.
    • setForceSendImmediately

      public void setForceSendImmediately(boolean force)
      Sets whether this packet should bypass the buffer and be sent immediately. If true, Pulse will flush the current buffer and send this packet instantly. Use this for latency-sensitive packets.
      Parameters:
      force - true to send immediately
    • isForceSendImmediately

      public boolean isForceSendImmediately()
      Checks if immediate sending is requested.
      Returns:
      true if forced
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Cancellable
    • setCancelled

      public void setCancelled(boolean cancel)
      Specified by:
      setCancelled in interface Cancellable
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      public static HandlerList getHandlerList()