[trunk] Worth: Don't default to 0.0, default to NaN.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1225 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
snowleo 2011-04-16 15:25:48 +00:00
parent a1b89ee75c
commit 8ede5aad01
3 changed files with 5 additions and 2 deletions

View File

@ -27,7 +27,7 @@ public class Worth implements IConf
result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase().replace("_", ""), Double.NaN);
}
if (Double.isNaN(result)) {
result = config.getDouble("worth-"+itemStack.getTypeId(), 0.0);
result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN);
}
return result;
}

View File

@ -37,7 +37,7 @@ public class Commandsell extends EssentialsCommand
boolean stack = args.length > 1 && args[1].endsWith("s");
boolean requireStack = parent.getConfiguration().getBoolean("trade-in-stacks-" + id, false);
if (worth < 1) {
if (Double.isNaN(worth)) {
throw new Exception("That item cannot be sold to the server.");
}
if (requireStack && !stack) {

View File

@ -37,6 +37,9 @@ public class Commandworth extends EssentialsCommand
is.setAmount(amount);
double worth = Essentials.getWorth().getPrice(is);
if (Double.isNaN(worth)) {
throw new Exception("That item cannot be sold to the server.");
}
user.charge(this);
user.sendMessage("§7Stack of " + is.getType().toString().toLowerCase().replace("_", "") + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)");