From 32c689e0f5a275d37df941d8e9e24caa62ef5890 Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 28 Mar 2012 10:36:10 +0200 Subject: [PATCH 1/2] Fix isAffordableFor in Trade class This fixes buy signs giving out items, when the player has essentials.eco.loan permission, but min-money in config is set to 0. --- Essentials/src/com/earth2me/essentials/Trade.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Trade.java b/Essentials/src/com/earth2me/essentials/Trade.java index fbdc471bd..502d3e34d 100644 --- a/Essentials/src/com/earth2me/essentials/Trade.java +++ b/Essentials/src/com/earth2me/essentials/Trade.java @@ -56,11 +56,9 @@ public class Trade public void isAffordableFor(final IUser user) throws ChargeException { - final double mon = user.getMoney(); if (getMoney() != null - && mon < getMoney() && getMoney() > 0 - && !user.isAuthorized("essentials.eco.loan")) + && user.canAfford(getMoney())) { throw new ChargeException(_("notEnoughMoney")); } @@ -71,12 +69,10 @@ public class Trade throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " "))); } + double money; if (command != null && !command.isEmpty() - && !user.isAuthorized("essentials.nocommandcost.all") - && !user.isAuthorized("essentials.nocommandcost." + command) - && mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command) - && 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command) - && !user.isAuthorized("essentials.eco.loan")) + && 0 < (money = getCommandCost(user)) + && user.canAfford(money)) { throw new ChargeException(_("notEnoughMoney")); } From 71d874484037b73e8eed93194d1f0a966bb389e1 Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 28 Mar 2012 11:21:31 +0200 Subject: [PATCH 2/2] Fix for the fix --- Essentials/src/com/earth2me/essentials/Trade.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Trade.java b/Essentials/src/com/earth2me/essentials/Trade.java index 502d3e34d..730037d9a 100644 --- a/Essentials/src/com/earth2me/essentials/Trade.java +++ b/Essentials/src/com/earth2me/essentials/Trade.java @@ -58,7 +58,7 @@ public class Trade { if (getMoney() != null && getMoney() > 0 - && user.canAfford(getMoney())) + && !user.canAfford(getMoney())) { throw new ChargeException(_("notEnoughMoney")); } @@ -72,7 +72,7 @@ public class Trade double money; if (command != null && !command.isEmpty() && 0 < (money = getCommandCost(user)) - && user.canAfford(money)) + && !user.canAfford(money)) { throw new ChargeException(_("notEnoughMoney")); }