summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-23 09:42:33 +0000
committersnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-23 09:42:33 +0000
commit626eeb6fb6c326e4484f849e1f8010977454afa0 (patch)
tree0aefbfdca15e40127f47a8387dea4d7ad85a193b
parentc47c6d6a687bed6ec016a42c999cf2db3459a86b (diff)
downloadEssentials-626eeb6fb6c326e4484f849e1f8010977454afa0.tar
Essentials-626eeb6fb6c326e4484f849e1f8010977454afa0.tar.gz
Essentials-626eeb6fb6c326e4484f849e1f8010977454afa0.tar.lz
Essentials-626eeb6fb6c326e4484f849e1f8010977454afa0.tar.xz
Essentials-626eeb6fb6c326e4484f849e1f8010977454afa0.zip
Don't charge if the cost is 0.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1531 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r--Essentials/src/com/earth2me/essentials/Charge.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Charge.java b/Essentials/src/com/earth2me/essentials/Charge.java
index d1dbcebc0..6f3379eb1 100644
--- a/Essentials/src/com/earth2me/essentials/Charge.java
+++ b/Essentials/src/com/earth2me/essentials/Charge.java
@@ -66,7 +66,7 @@ public class Charge
public void charge(User user) throws Exception
{
double mon = user.getMoney();
- if (costs != null)
+ if (costs != null && costs != 0.0)
{
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
{
@@ -92,13 +92,16 @@ public class Charge
return;
}
- double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
- if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
+ int cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
+ if (cost != 0)
{
- throw new Exception(Util.i18n("notEnoughMoney"));
+ if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
+ {
+ throw new Exception(Util.i18n("notEnoughMoney"));
+ }
+ user.takeMoney(cost);
+ user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(cost)));
}
- user.takeMoney(cost);
- user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(cost)));
}
}
}