Workaround for TPS

This commit is contained in:
Carlos 2022-04-24 12:00:35 +02:00
parent c5799af7dc
commit dc1ad6d418

View File

@ -35,6 +35,7 @@ public class TpsCommand implements WSCommand {
* @return Current server Tps
*/
public double[] getTps() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
try {
Class<?> minecraftServerClass = Class.forName("net.minecraft.server." + mcVer + ".MinecraftServer");
Method getServerMethod = minecraftServerClass.getDeclaredMethod("getServer");
Object serverInstance = getServerMethod.invoke(null);
@ -44,6 +45,10 @@ public class TpsCommand implements WSCommand {
recentTps[i] = Math.round(recentTps[i]);
}
return recentTps;
} catch (Exception e) {
//If an uncaught exception is thrown, maybe it is because this method of getting TPS does not work in the MV version currently running..
return new double[] { 0 };
}
}
}