Implement the ServerData packet by firing ProxyPingEvent (#771)

* Implement the ServerData packet by firing ProxyPingEvent

Mojang introduced the enable-status server property with Minecraft 1.19, which if enabled causes servers to close the connection when a client tries to ping them. Mojang wants to show the MOTD and favicon on the server select screen for those who manage to log in, so we need to implement this packet as well.

The good news is that we can send this packet as many times as needed on the same connection

This matches the behavior of pinging the server. This is a minor, but completely backwards-compatible, API breakage: Player inherits from InboundConnection so we do not have to change ProxyPingEvent, however plugins not expecting a Player might get confused.

* typo
This commit is contained in:
Andrew Steinborn
2022-06-23 23:59:13 -04:00
committed by GitHub
parent 86c65f3910
commit 662fbc4e3c
12 changed files with 330 additions and 133 deletions

View File

@@ -13,10 +13,11 @@ import com.velocitypowered.api.proxy.InboundConnection;
import com.velocitypowered.api.proxy.server.ServerPing;
/**
* This event is fired when a server list ping request is sent by a remote client. Velocity will
* 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 be as parsimonious as possible when handling this event due to the amount of
* ping packets a client can send.
* 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.
*/
@AwaitingEvent
public final class ProxyPingEvent {