From bd797b59fe3dd4916eead8157ad13c250b7bb877 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 20 Jan 2019 15:56:49 +0000 Subject: [PATCH] Allow disabling of scientific notation (disabled by default) for DoubleFlags --- .../plotsquared/plot/config/Settings.java | 4 ++++ .../plotsquared/plot/util/MainUtil.java | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java index bafc5a2ec..f901744f8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java @@ -221,6 +221,10 @@ public class Settings extends Config { @Ignore public static boolean NATIVE_UUID_PROVIDER = false; } + @Comment("General settings") public static final class General { + @Comment("Display scientific numbers (4.2E8)") public static boolean SCIENTIFIC = false; + } + @Comment("Configure the paths that will be used") public static final class Paths { public static String SCHEMATICS = "schematics"; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java index 5cbecb16d..906c70595 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java @@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.C; import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.database.DBFunc; +import com.github.intellectualsites.plotsquared.plot.flag.DoubleFlag; import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.Flags; @@ -18,6 +19,7 @@ import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; +import java.text.DecimalFormat; import java.util.*; import java.util.Map.Entry; @@ -749,8 +751,13 @@ public class MainUtil { } else { String prefix = ""; for (Entry, Object> entry : flagMap.entrySet()) { - flags.append(prefix) - .append(C.PLOT_FLAG_LIST.f(entry.getKey().getName(), entry.getValue())); + Object value = entry.getValue(); + if (entry.getKey() instanceof DoubleFlag && !Settings.General.SCIENTIFIC) { + DecimalFormat df = new DecimalFormat("0"); + df.setMaximumFractionDigits(340); + value = df.format(value); + } + flags.append(prefix).append(C.PLOT_FLAG_LIST.f(entry.getKey().getName(), value)); prefix = ", "; } }