mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Caching getTPS some reflect tools
Former-commit-id: 82e3967453d79c991753df96beb33876f77a24d6
This commit is contained in:
1 parent
25ca1f13b5
commit
e3223cb1e4
1 file changed
+12
-10
@@ -1271,16 +1271,18 @@ public class Util {
|
||||
* @return TPS (e.g 19.92)
|
||||
*/
|
||||
public static Double getTPS() {
|
||||
try {
|
||||
serverInstance = getNMSClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||
tpsField = serverInstance.getClass().getField("recentTps");
|
||||
} catch (NoSuchFieldException
|
||||
| SecurityException
|
||||
| IllegalAccessException
|
||||
| IllegalArgumentException
|
||||
| InvocationTargetException
|
||||
| NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
if(serverInstance == null || tpsField == null) {
|
||||
try {
|
||||
serverInstance = getNMSClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||
tpsField = serverInstance.getClass().getField("recentTps");
|
||||
} catch (NoSuchFieldException
|
||||
| SecurityException
|
||||
| IllegalAccessException
|
||||
| IllegalArgumentException
|
||||
| InvocationTargetException
|
||||
| NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
double[] tps = ((double[]) tpsField.get(serverInstance));
|
||||
|
||||
Reference in new issue
Block a user