From f8fcba26b368e5c38db4a9613dc6dd15c99f1825 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 9 May 2021 17:20:50 +1000 Subject: [PATCH] #606: Add Player#getPing to access the player's ping By: retrooper --- .../src/main/java/org/bukkit/entity/Player.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index 41be187d6e..0574d4073a 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -1221,6 +1221,21 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public int getClientViewDistance(); + /** + * Gets the player's estimated ping in milliseconds. + * + * In Vanilla this value represents the average of the response time to the + * last four application layer ping packets sent. This value does not + * represent the network round trip time and as such may have less + * granularity and be impacted by other sources. For these reasons it + * should not be used for anti-cheat purposes. Its recommended use is + * only as a qualitative indicator of connection quality (Vanilla + * uses it for this purpose in the tab list). + * + * @return player ping + */ + public int getPing(); + /** * Gets the player's current locale. *