Skip to content

Instantly share code, notes, and snippets.

private int getPing(Player player) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
Method method = player.getClass().getDeclaredMethod("getHandle");
method.setAccessible(true);
Object handle = method.invoke(player);
return ((Integer) handle.getClass().getField("ping").get(handle)).intValue();
}