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
ConstructorDescriptionClientPingServerEvent
(@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 TypeMethodDescriptionvoid
Adds to the delay until minestom will send the ping response packet.@NotNull PlayerConnection
PlayerConnection of received packet.@NotNull Duration
getDelay()
Gets the delay until minestom will send the ping response packet.long
Payload of received packet.boolean
Gets if theEvent
should be cancelled or not.void
noDelay()
Clears the delay until minestom will send the ping response packet.void
setCancelled
(boolean cancel) Cancelling this event will cause the server to appear offline in the vanilla server list.void
Sets the delay until minestom will send the ping response packet.void
setPayload
(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:CancellableEvent
Gets if theEvent
should be cancelled or not.- Specified by:
isCancelled
in 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:
setCancelled
in interfaceCancellableEvent
- Parameters:
cancel
- true if the event should be cancelled, false otherwise
-