diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-07-19 00:55:21 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-07-19 00:55:21 +0100 |
commit | adf0eedbbb315c99b97bc5cce89ff0d8f3e4d206 (patch) | |
tree | 207547cef029d45c4228bbd7752dfe64b4da83e0 | |
parent | 439ce03542a4cab8e33cf0006fb6cf746d6b061b (diff) | |
download | Essentials-adf0eedbbb315c99b97bc5cce89ff0d8f3e4d206.tar Essentials-adf0eedbbb315c99b97bc5cce89ff0d8f3e4d206.tar.gz Essentials-adf0eedbbb315c99b97bc5cce89ff0d8f3e4d206.tar.lz Essentials-adf0eedbbb315c99b97bc5cce89ff0d8f3e4d206.tar.xz Essentials-adf0eedbbb315c99b97bc5cce89ff0d8f3e4d206.zip |
Cleanup worth and sell messages
3 files changed, 17 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ItemDb.java b/Essentials/src/com/earth2me/essentials/ItemDb.java index 6a7af9b7d..b1afe4576 100644 --- a/Essentials/src/com/earth2me/essentials/ItemDb.java +++ b/Essentials/src/com/earth2me/essentials/ItemDb.java @@ -181,7 +181,12 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { is.add(get(args[0])); } - + + if (is.isEmpty() || is.get(0).getType() == Material.AIR) + { + throw new Exception(_("itemSellAir")); + } + return is; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index c4931c00a..61c05ce07 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -59,7 +59,7 @@ public class Commandsell extends EssentialsCommand } } } - if (count > 1 && totalWorth.signum() > 0) + if (count != 1) { if (args[0].equalsIgnoreCase("blocks")) { @@ -84,6 +84,9 @@ public class Commandsell extends EssentialsCommand if (amount <= 0) { + if (!isBulkSell) { + user.sendMessage(_("itemSold", NumberUtil.displayCurrency(BigDecimal.ZERO, ess), BigDecimal.ZERO, is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(worth, ess))); + } return BigDecimal.ZERO; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index bc832a44b..fa2e106f7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -56,9 +56,9 @@ public class Commandworth extends EssentialsCommand } } } - if (count > 1 && totalWorth.signum() > 0) + if (count > 1) { - if (args[0].equalsIgnoreCase("blocks")) + if (args.length > 0 && args[0].equalsIgnoreCase("blocks")) { user.sendMessage(_("totalSellableBlocks", type, NumberUtil.displayCurrency(totalWorth, ess))); } @@ -113,6 +113,11 @@ public class Commandworth extends EssentialsCommand throw new Exception(_("itemCannotBeSold")); } + if (amount < 0) + { + amount = 0; + } + BigDecimal result = worth.multiply(BigDecimal.valueOf(amount)); sender.sendMessage(is.getDurability() != 0 |