Allow disabling of scientific notation (disabled by default) for DoubleFlags

This commit is contained in:
dordsor21 2019-01-20 15:56:49 +00:00
parent 0609b3d7f6
commit bd797b59fe
2 changed files with 13 additions and 2 deletions

View file

@ -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";

View file

@ -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<Flag<?>, 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 = ", ";
}
}