Class ProxyPingEvent

java.lang.Object
com.velocitypowered.api.event.proxy.ProxyPingEvent
All Implemented Interfaces:
ResultedEvent<ResultedEvent.GenericResult>

@AwaitingEvent public final class ProxyPingEvent extends Object implements ResultedEvent<ResultedEvent.GenericResult>
This event is fired when a request for server information is sent by a remote client, or when the server sends the MOTD and favicon to the client after a successful login. Velocity will wait on this event to finish firing before delivering the results to the remote client, but you are urged to handle this event as quickly as possible when handling this event due to the amount of ping packets a client can send.
  • Constructor Details

  • Method Details

    • getConnection

      public InboundConnection getConnection()
      Obtain the connection to which the corresponding ServerPing will be sent.
      Returns:
      the connection that has sent the ServerPing request
    • getPing

      public ServerPing getPing()
      Get the ServerPing to send to the connection.
      Returns:
      the ServerPing to send
    • setPing

      public void setPing(@NotNull @NotNull ServerPing ping)
      Sets the ServerPing to send to the connection.
      Parameters:
      ping - sets the ServerPing to send
    • getResult

      public ResultedEvent.GenericResult getResult()
      Gets whether to avoid sending a ping response to the connection.
      Specified by:
      getResult in interface ResultedEvent<ResultedEvent.GenericResult>
      Returns:
      if a ping response to the connection will be avoided
      API Note:
      For the ProxyPingEvent executed to obtain the MOTD for the ServerData sent to players of versions higher than 1.19.1, the cancellation of this event will have no effect.
    • setResult

      public void setResult(@NotNull @NotNull ResultedEvent.GenericResult result)
      Sets whether to avoid sending a ping response to the connection. This will automatically close the connection.
      Specified by:
      setResult in interface ResultedEvent<ResultedEvent.GenericResult>
      Parameters:
      result - if a ping response to the connection will be avoided
      API Note:
      For the ProxyPingEvent executed to obtain the MOTD for the ServerData sent to players of versions higher than 1.19.1, the cancellation of this event will have no effect.
    • toString

      public String toString()
      Overrides:
      toString in class Object