From 8ede5aad0185e2411fb762e4b62bdda5c56557ac Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 16 Apr 2011 15:25:48 +0000 Subject: [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 --- Essentials/src/com/earth2me/essentials/Worth.java | 2 +- Essentials/src/com/earth2me/essentials/commands/Commandsell.java | 2 +- Essentials/src/com/earth2me/essentials/commands/Commandworth.java | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index d95f264ee..c9f6b0890 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -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; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index d651c882f..7d66284b1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -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) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index aee5041c2..82a8729ee 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -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)"); -- cgit v1.2.3