Created
May 21, 2015 00:00
-
-
Save vemacs/1550cac797314a2c841f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Method getHandleMethod; | |
private static Field pingField; | |
private static int getPing(Player player) { | |
try { | |
if (getHandleMethod == null) { | |
getHandleMethod = player.getClass().getDeclaredMethod("getHandle"); | |
getHandleMethod.setAccessible(true); | |
} | |
Object entityPlayer = getHandleMethod.invoke(player); | |
if (pingField == null) { | |
pingField = entityPlayer.getClass().getDeclaredField("ping"); | |
pingField.setAccessible(true); | |
} | |
return pingField.getInt(entityPlayer); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment