diff options
4 files changed, 11 insertions, 7 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java index ee3592a..16eadc8 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java @@ -48,6 +48,7 @@ import java.lang.management.MemoryType; import java.lang.management.MemoryUsage; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Consumer; @@ -376,7 +377,7 @@ public class HealthModule implements CommandModule { .content(" ") .append(FormatUtil.formatBytes(bytesPerSec, GREEN, "/s")) .append(text(" / ")) - .append(text(String.format("%,d", packetsPerSec), WHITE)) + .append(text(String.format(Locale.ENGLISH, "%,d", packetsPerSec), WHITE)) .append(text(" pps ")) .append(text().color(DARK_GRAY) .append(text('(')) diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkInterfaceInfo.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkInterfaceInfo.java index 6ec700b..bd9e187 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkInterfaceInfo.java +++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/net/NetworkInterfaceInfo.java @@ -200,7 +200,7 @@ public final class NetworkInterfaceInfo { } } - private static final Pattern PROC_NET_DEV_PATTERN = Pattern.compile("^\\s+(\\w+):([\\d\\s]+)$"); + private static final Pattern PROC_NET_DEV_PATTERN = Pattern.compile("^\\s*(\\w+):([\\d\\s]+)$"); private static @NonNull Map<String, NetworkInterfaceInfo> read(List<String> output) { // Inter-| Receive | Transmit diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java b/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java index cbc496d..c4a3d66 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java +++ b/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java @@ -23,6 +23,8 @@ package me.lucko.spark.common.util; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextColor; +import java.util.Locale; + public enum FormatUtil { ; @@ -34,23 +36,23 @@ public enum FormatUtil { } public static String formatBytes(long bytes) { - if (bytes == 0) { + if (bytes <= 0) { return "0 bytes"; } int sizeIndex = (int) (Math.log(bytes) / Math.log(1024)); - return String.format("%.1f", bytes / Math.pow(1024, sizeIndex)) + " " + SIZE_UNITS[sizeIndex]; + return String.format(Locale.ENGLISH, "%.1f", bytes / Math.pow(1024, sizeIndex)) + " " + SIZE_UNITS[sizeIndex]; } public static Component formatBytes(long bytes, TextColor color, String suffix) { String value; String unit; - if (bytes == 0) { + if (bytes <= 0) { value = "0"; unit = "KB" + suffix; } else { int sizeIndex = (int) (Math.log(bytes) / Math.log(1024)); - value = String.format("%.1f", bytes / Math.pow(1024, sizeIndex)); + value = String.format(Locale.ENGLISH, "%.1f", bytes / Math.pow(1024, sizeIndex)); unit = SIZE_UNITS[sizeIndex] + suffix; } diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java b/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java index 24e49fa..22ee9bb 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java +++ b/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java @@ -27,6 +27,7 @@ import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.TextColor; import java.lang.management.MemoryUsage; +import java.util.Locale; import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; @@ -76,7 +77,7 @@ public enum StatisticFormatter { color = GREEN; } - return text(String.format("%.1f", duration), color); + return text(String.format(Locale.ENGLISH, "%.1f", duration), color); } public static TextComponent formatCpuUsage(double usage) { |