Abort transaction before updating funds on balance overflow.

This commit is contained in:
KHobbits 2014-05-25 17:03:23 +01:00
parent ada2fe01a2
commit 889dde7549
2 changed files with 10 additions and 6 deletions

View file

@ -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)
{