You can now access the old balance during the UserBalanceUpdateEvent Event

This commit is contained in:
Dykam 2014-03-04 19:44:55 +00:00 committed by KHobbits
parent ee986768ce
commit 28ec7c2d80
2 changed files with 10 additions and 2 deletions

View file

@ -444,6 +444,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
}
return;
}
final BigDecimal oldBalance = _getMoney();
if (Methods.hasMethod())
{
try
@ -461,7 +462,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
}
}
super.setMoney(value, true);
ess.getServer().getPluginManager().callEvent(new UserBalanceUpdateEvent(this.getBase(), value));
ess.getServer().getPluginManager().callEvent(new UserBalanceUpdateEvent(this.getBase(), oldBalance, value));
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
}

View file

@ -11,11 +11,13 @@ public class UserBalanceUpdateEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final BigDecimal originalBalance;
private final BigDecimal balance;
public UserBalanceUpdateEvent(Player player, BigDecimal balance)
public UserBalanceUpdateEvent(Player player, BigDecimal originalBalance, BigDecimal balance)
{
this.player = player;
this.originalBalance = originalBalance;
this.balance = balance;
}
@ -39,4 +41,9 @@ public class UserBalanceUpdateEvent extends Event
{
return balance;
}
public BigDecimal getOldBalance()
{
return originalBalance;
}
}