Package net.minestom.server.event.server
Class ClientPingServerEvent
java.lang.Object
net.minestom.server.event.server.ClientPingServerEvent
- All Implemented Interfaces:
Event,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 Summary
ConstructorsConstructorDescriptionClientPingServerEvent(@NotNull PlayerConnection connection, long payload) Creates a new client ping server event with 0 delayClientPingServerEvent(@NotNull PlayerConnection connection, long payload, Duration delay) Creates a new client ping server event with 0 delay -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds to the delay until minestom will send the ping response packet.@NotNull PlayerConnectionPlayerConnection of received packet.@NotNull DurationgetDelay()Gets the delay until minestom will send the ping response packet.longPayload of received packet.booleanGets if theEventshould be cancelled or not.voidnoDelay()Clears the delay until minestom will send the ping response packet.voidsetCancelled(boolean cancel) Cancelling this event will cause the server to appear offline in the vanilla server list.voidSets the delay until minestom will send the ping response packet.voidsetPayload(long payload) Sets the payload to respond with.
-
Constructor Details
-
ClientPingServerEvent
Creates a new client ping server event with 0 delay- Parameters:
connection- the player connectionpayload- 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 connectionpayload- the payload the client sent
-
-
Method Details
-
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
Gets the delay until minestom will send the ping response packet.- Returns:
- the delay
-
addDelay
Adds to the delay until minestom will send the ping response packet.- Parameters:
delay- the delay
-
setDelay
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: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.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancel- true if the event should be cancelled, false otherwise
-