Added number formatting to display big numbers with commas (#70)

This commit is contained in:
Artemis-the-gr8 2022-06-23 20:31:40 +02:00
parent b6be510462
commit e8f17afa8f
2 changed files with 22 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import com.gmail.artemis.the.gr8.playerstats.enums.Query;
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.gmail.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
import com.gmail.artemis.the.gr8.playerstats.utils.NumberFormatter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent;
@ -327,7 +328,7 @@ public class MessageFactory {
}
protected TextComponent statNumberComponent(Query selection, long number) {
return getComponent(number + "",
return getComponent(NumberFormatter.format(number),
getColorFromString(config.getStatNumberFormatting(selection, false)),
getStyleFromString(config.getStatNumberFormatting(selection, true)));
}

View File

@ -0,0 +1,20 @@
package com.gmail.artemis.the.gr8.playerstats.utils;
import java.text.DecimalFormat;
public class NumberFormatter {
private static final DecimalFormat format;
static{
format = new DecimalFormat();
format.setGroupingUsed(true);
format.setGroupingSize(3);
}
private NumberFormatter(){
}
public static String format(long number) {
return format.format(number);
}
}