diff options
author | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-04-16 17:26:32 +0000 |
---|---|---|
committer | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-04-16 17:26:32 +0000 |
commit | 7a4c62569137233af6bd0269a9e2d6100330b885 (patch) | |
tree | a7a27371a35962a1740408859660772d98fa0e19 | |
parent | 6d1bb4028fffa8ad8b408bf18d6408dc625dd873 (diff) | |
download | Essentials-7a4c62569137233af6bd0269a9e2d6100330b885.tar Essentials-7a4c62569137233af6bd0269a9e2d6100330b885.tar.gz Essentials-7a4c62569137233af6bd0269a9e2d6100330b885.tar.lz Essentials-7a4c62569137233af6bd0269a9e2d6100330b885.tar.xz Essentials-7a4c62569137233af6bd0269a9e2d6100330b885.zip |
[trunk] EssentialsConf: getDouble(): do not change the config on get() if the value is not set
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1233 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsConf.java | 9 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Worth.java | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index 054fd1840..0f47f8471 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -182,4 +182,13 @@ public class EssentialsConf extends Configuration } return num.longValue(); } + + @Override + public double getDouble(String path, double def) { + Number num = (Number)getProperty(path); + if (num == null) { + return def; + } + return num.doubleValue(); + } } diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index c9f6b0890..470386544 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -19,12 +19,14 @@ public class Worth implements IConf public double getPrice(ItemStack itemStack) { - double result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), Double.NaN); + String itemname = itemStack.getType().toString().toLowerCase().replace("_", ""); + double result; + result = config.getDouble("worth."+itemname+"."+itemStack.getDurability(), Double.NaN); if (Double.isNaN(result)) { - result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase().replace("_", "")+".0", Double.NaN); + result = config.getDouble("worth."+itemname+".0", Double.NaN); } if (Double.isNaN(result)) { - result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase().replace("_", ""), Double.NaN); + result = config.getDouble("worth."+itemname, Double.NaN); } if (Double.isNaN(result)) { result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN); @@ -38,7 +40,6 @@ public class Worth implements IConf config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price); } else { // Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0. - itemStack.getData(); config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), price); } config.removeProperty("worth-"+itemStack.getTypeId()); |