summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandeco.java4
2 files changed, 10 insertions, 6 deletions
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index c312fbe84..ee0650388 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -115,17 +115,19 @@ public abstract class UserData extends PlayerExtension implements IConf
}
public void setMoney(BigDecimal value, boolean throwError) throws MaxMoneyException
- {
- money = value;
+ {
BigDecimal maxMoney = ess.getSettings().getMaxMoney();
BigDecimal minMoney = ess.getSettings().getMinMoney();
- if (money.compareTo(maxMoney) > 0)
- {
- money = maxMoney;
+ if (value.compareTo(maxMoney) > 0)
+ {
if (throwError)
{
throw new MaxMoneyException();
}
+ money = maxMoney;
+ }
+ else {
+ money = value;
}
if (money.compareTo(minMoney) < 0)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
index 5efe54818..f589dcfed 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
@@ -105,8 +105,10 @@ public class Commandeco extends EssentialsLoopCommand
private void set(BigDecimal amount, final User player, final CommandSource sender) throws MaxMoneyException
{
BigDecimal minBalance = ess.getSettings().getMinMoney();
+ BigDecimal maxBalance = ess.getSettings().getMaxMoney();
boolean underMinimum = (amount.compareTo(minBalance) < 0);
- player.setMoney(underMinimum ? minBalance : amount);
+ boolean aboveMax = (amount.compareTo(maxBalance) > 0);
+ player.setMoney(underMinimum ? minBalance : aboveMax ? maxBalance : amount);
player.sendMessage(tl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess)));
if (sender != null)
{