From 60c701d20bb5845cf13abee7372adba68e7961fd Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 28 Jun 2021 18:49:03 +0200 Subject: [PATCH] Don't display plot rating placeholder in scientific notation Fixes #3091 --- .../core/util/placeholders/PlaceholderRegistry.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java index 1015442df..5520eeacc 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java @@ -45,6 +45,8 @@ import net.kyori.adventure.text.minimessage.MiniMessage; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Collections; @@ -182,7 +184,12 @@ public final class PlaceholderRegistry { if (Double.isNaN(plot.getAverageRating())) { return legacyComponent(TranslatableCaption.of("placeholder.nan"), player); } - return Double.toString(plot.getAverageRating()); + BigDecimal roundRating = BigDecimal.valueOf(plot.getAverageRating()).setScale(2, RoundingMode.HALF_UP); + if (!Settings.General.SCIENTIFIC) { + return String.valueOf(roundRating); + } else { + return Double.toString(plot.getAverageRating()); + } }); this.createPlaceholder("currentplot_biome", (player, plot) -> plot.getBiomeSynchronous().toString()); }