From 7220051c18aff0e180730a46040cf9702d7d8764 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 31 Dec 2021 22:21:25 +0100 Subject: [PATCH] Rework --- .../steamwar/bungeecore/commands/PlaytimeCommand.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index 0aaca7c..c5ff347 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -23,8 +23,11 @@ import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; +import org.apache.commons.lang3.LocaleUtils; import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Locale; public class PlaytimeCommand extends BasicCommand{ @@ -37,9 +40,10 @@ public class PlaytimeCommand extends BasicCommand{ if(!(sender instanceof ProxiedPlayer)) return; - String s = Message.parse("DECIMAL_FORMAT", sender); - String format = new DecimalFormat(s).format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); + NumberFormat format = NumberFormat.getNumberInstance(LocaleUtils.toLocale(Message.parse("DECIMAL_FORMAT", sender))); + format.setMaximumFractionDigits(2); + String formattedText = format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); - Message.send(Message.parse("HOURS_PLAYED", sender) + format,sender); + Message.send(Message.parse("HOURS_PLAYED", sender) + formattedText,sender); } }