mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-30 20:11:36 +01:00
[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
This commit is contained in:
parent
307ecced06
commit
e547b0f006
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user