Package net.minestom.server.event.server
Class ServerListPingEvent
java.lang.Object
net.minestom.server.event.server.ServerListPingEvent
- All Implemented Interfaces:
Event,CancellableEvent
Called when a
PlayerConnection sends a status packet,
usually to display information on the server list.-
Constructor Summary
ConstructorsConstructorDescriptionServerListPingEvent(@Nullable PlayerConnection connection, @NotNull ServerListPingType type) Creates a new server list ping event.ServerListPingEvent(@NotNull ServerListPingType type) Creates a new server list ping event with no player connection. -
Method Summary
Modifier and TypeMethodDescription@Nullable PlayerConnectionPlayerConnection of received packet.@NotNull ServerListPingTypeGets the ping type that the client is pinging with.@NotNull ResponseDataGets the response data that is sent to the client.booleanGets if theEventshould be cancelled or not.voidsetCancelled(boolean cancel) Cancelling this event will cause the server to appear offline in the vanilla server list.voidsetResponseData(@NotNull ResponseData responseData) Sets the response data, overwriting the exiting data.
-
Constructor Details
-
ServerListPingEvent
Creates a new server list ping event with no player connection.- Parameters:
type- the ping type to respond with
-
ServerListPingEvent
public ServerListPingEvent(@Nullable @Nullable PlayerConnection connection, @NotNull @NotNull ServerListPingType type) Creates a new server list ping event.- Parameters:
connection- the player connection, if the ping type is moderntype- the ping type to respond with
-
-
Method Details
-
getResponseData
Gets the response data that is sent to the client. This is mutable and can be modified to change what is returned.- Returns:
- the response data being returned
-
setResponseData
Sets the response data, overwriting the exiting data.- Parameters:
responseData- the new data
-
getConnection
PlayerConnection of received packet. Note that the player has not joined the server at this time. This will only be non-null for modern server list pings.- Returns:
- the playerConnection.
-
getPingType
Gets the ping type that the client is pinging with.- Returns:
- the ping type
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEventGets if theEventshould be cancelled or not.- Specified by:
isCancelledin interfaceCancellableEvent- 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. Note that this will have no effect if the ping version isServerListPingType.OPEN_TO_LAN.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancel- true if the event should be cancelled, false otherwise
-