From 3e025ef8be559b719560e0d2c203910dc62d8f3c Mon Sep 17 00:00:00 2001 From: garbagemule Date: Sat, 1 Mar 2014 13:58:24 +0100 Subject: [PATCH] Enforce English locale for decimal formatting in config-file. --- resources/plugin.yml | 2 +- .../MobArena/util/config/ConfigUtils.java | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 80c7f20..5d95601 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,7 +1,7 @@ name: MobArena author: garbagemule main: com.garbagemule.MobArena.MobArena -version: 0.96.2.13 +version: 0.96.2.14 softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault] commands: ma: diff --git a/src/com/garbagemule/MobArena/util/config/ConfigUtils.java b/src/com/garbagemule/MobArena/util/config/ConfigUtils.java index 1cbe8d3..3f87bda 100644 --- a/src/com/garbagemule/MobArena/util/config/ConfigUtils.java +++ b/src/com/garbagemule/MobArena/util/config/ConfigUtils.java @@ -9,8 +9,9 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; import java.io.File; -import java.io.InputStream; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; import java.util.Set; public class ConfigUtils @@ -111,12 +112,8 @@ public class ConfigUtils String world = location.getWorld().getName(); - StringBuilder buffy = new StringBuilder(); - buffy.append(x).append(",").append(y).append(",").append(z); - buffy.append(",").append(yaw).append(",").append(pit); - buffy.append(",").append(world); - - config.set(path, buffy.toString()); + String value = x + "," + y + "," + z + "," + yaw + "," + pit + "," + world; + config.set(path, value); } private static String twoPlaces(double value, boolean force) { @@ -126,6 +123,11 @@ public class ConfigUtils private static String twoPlaces(double value) { return twoPlaces(value, false); } + private static final DecimalFormat DF_NORMAL = new DecimalFormat("0.##"); private static final DecimalFormat DF_FORCE = new DecimalFormat("0.0#"); + static { + DF_FORCE.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH)); + DF_NORMAL.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH)); + } }