Class ClientPingServerEvent

java.lang.Object
net.minestom.server.event.server.ClientPingServerEvent
All Implemented Interfaces:
Event, CancellableEvent

public class ClientPingServerEvent extends Object implements CancellableEvent
Called when a PlayerConnection sends a ping packet, usually after the status packet. Only used in versions since the netty rewrite; 1.7+
See Also:
  • Constructor Details

    • ClientPingServerEvent

      public ClientPingServerEvent(@NotNull @NotNull PlayerConnection connection, long payload)
      Creates a new client ping server event with 0 delay
      Parameters:
      connection - the player connection
      payload - the payload the client sent
    • ClientPingServerEvent

      public ClientPingServerEvent(@NotNull @NotNull PlayerConnection connection, long payload, Duration delay)
      Creates a new client ping server event with 0 delay
      Parameters:
      connection - the player connection
      payload - the payload the client sent
  • Method Details

    • getConnection

      @NotNull public @NotNull PlayerConnection getConnection()
      PlayerConnection of received packet. Note that the player has not joined the server at this time.
      Returns:
      the connection.
    • getPayload

      public long getPayload()
      Payload of received packet. May be any number; vanilla uses a system dependant time value.
      Returns:
      the payload
    • setPayload

      public void setPayload(long payload)
      Sets the payload to respond with.

      Note: This should be the same as the client sent, however vanilla 1.17 seems to be OK with a different payload.

      Parameters:
      payload - the payload
    • getDelay

      @NotNull public @NotNull Duration getDelay()
      Gets the delay until minestom will send the ping response packet.
      Returns:
      the delay
    • addDelay

      public void addDelay(@NotNull @NotNull Duration delay)
      Adds to the delay until minestom will send the ping response packet.
      Parameters:
      delay - the delay
    • setDelay

      public void setDelay(@NotNull @NotNull Duration delay)
      Sets the delay until minestom will send the ping response packet.
      Parameters:
      delay - the delay
    • noDelay

      public void noDelay()
      Clears the delay until minestom will send the ping response packet.
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: CancellableEvent
      Gets if the Event should be cancelled or not.
      Specified by:
      isCancelled in interface CancellableEvent
      Returns:
      true if the event should be cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Cancelling this event will cause the server to appear offline in the vanilla server list.
      Specified by:
      setCancelled in interface CancellableEvent
      Parameters:
      cancel - true if the event should be cancelled, false otherwise