mirror of
https://github.com/itHotL/PlayerStats.git
synced 2025-01-23 21:51:19 +01:00
Added number formatting to display big numbers with commas (#70)
This commit is contained in:
parent
b6be510462
commit
e8f17afa8f
@ -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.config.ConfigHandler;
|
||||||
import com.gmail.artemis.the.gr8.playerstats.utils.EnumHandler;
|
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.MyLogger;
|
||||||
|
import com.gmail.artemis.the.gr8.playerstats.utils.NumberFormatter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
@ -327,7 +328,7 @@ public class MessageFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected TextComponent statNumberComponent(Query selection, long number) {
|
protected TextComponent statNumberComponent(Query selection, long number) {
|
||||||
return getComponent(number + "",
|
return getComponent(NumberFormatter.format(number),
|
||||||
getColorFromString(config.getStatNumberFormatting(selection, false)),
|
getColorFromString(config.getStatNumberFormatting(selection, false)),
|
||||||
getStyleFromString(config.getStatNumberFormatting(selection, true)));
|
getStyleFromString(config.getStatNumberFormatting(selection, true)));
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user