-
-
Save hugo4715/2613ac04356d3e7f3693 to your computer and use it in GitHub Desktop.
This file contains hidden or 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[] {-1, -1, -1}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment