mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-12 15:56:00 +08:00
Fixed rounding
Fixed Byte to Megabyte conversion
This commit is contained in:
parent
71f7210a82
commit
2e5c75aede
@ -76,7 +76,7 @@ public class TPSCountTimer extends AbsRunnable {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
|
||||
long totalMemory = runtime.totalMemory();
|
||||
long usedMemory = (totalMemory - runtime.freeMemory()) / (1024L * 1024L);
|
||||
long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000;
|
||||
|
||||
int playersOnline = plugin.getServer().getOnlinePlayers().size();
|
||||
int loadedChunks = getLoadedChunks();
|
||||
@ -114,7 +114,7 @@ public class TPSCountTimer extends AbsRunnable {
|
||||
diff -= twentySeconds;
|
||||
}
|
||||
|
||||
double tpsN = twentySeconds / diff;
|
||||
double tpsN = MathUtils.round(twentySeconds / diff);
|
||||
|
||||
return new TPS(now, tpsN, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded);
|
||||
}
|
||||
|
@ -179,6 +179,8 @@ public class MathUtils {
|
||||
* @return The rounded number
|
||||
*/
|
||||
public static double round(double number) {
|
||||
return Double.valueOf(decimalFormat.format(number));
|
||||
String formattedNumber = decimalFormat.format(number);
|
||||
formattedNumber = formattedNumber.substring(0, 3); //Fix for unknown reasons for not-rounding
|
||||
return Double.valueOf(formattedNumber);
|
||||
}
|
||||
}
|
||||
|
@ -154,5 +154,4 @@ public class MathUtilsTest {
|
||||
double result = MathUtils.sumDouble(l.stream());
|
||||
assertTrue(result + "/" + exp, exp == result);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user