mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-15 05:33:40 +00: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
2 changed files with 14 additions and 4 deletions
|
@ -182,4 +182,13 @@ public class EssentialsConf extends Configuration
|
||||||
}
|
}
|
||||||
return num.longValue();
|
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)
|
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)) {
|
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)) {
|
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)) {
|
if (Double.isNaN(result)) {
|
||||||
result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN);
|
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);
|
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price);
|
||||||
} else {
|
} else {
|
||||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
// 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.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), price);
|
||||||
}
|
}
|
||||||
config.removeProperty("worth-"+itemStack.getTypeId());
|
config.removeProperty("worth-"+itemStack.getTypeId());
|
||||||
|
|
Loading…
Reference in a new issue