Last active
August 28, 2016 23:34
-
-
Save vemacs/6a345b2f9822b79a9a7f 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 Object minecraftServer; | |
private static Field recentTps; | |
public static double[] getRecentTps() { | |
try { | |
if (minecraftServer == null) { | |
Server server = Bukkit.getServer(); | |
Field consoleField = server.getClass().getDeclaredField("console"); | |
consoleField.setAccessible(true); | |
minecraftServer = consoleField.get(server); | |
} | |
if (recentTps == null) { | |
recentTps = minecraftServer.getClass().getSuperclass().getDeclaredField("recentTps"); | |
recentTps.setAccessible(true); | |
} | |
return (double[]) recentTps.get(minecraftServer); | |
} catch (IllegalAccessException | NoSuchFieldException ignored) { | |
} | |
return new double[] {20, 20, 20}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What information does that array include exactly?