change to (hopefully) prevent index out of bounds exception + return "-" when fromPercentage == 0

This commit is contained in:
LunarAkai 2024-04-05 22:20:01 +02:00
commit c8978e2625
4 changed files with 12 additions and 3 deletions

View file

@ -30,6 +30,9 @@ public class MinecleanerStringUtil {
}
public static String percentageString(int whatPercentage, int fromPercentage) {
if(fromPercentage == 0) {
return "-";
}
float percent = (float) whatPercentage/fromPercentage;
percent = percent * 100;
String percentageString = String.format("%.1f", percent);