1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-09 16:17:37 +02:00

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; return;
} }
final BigDecimal oldBalance = _getMoney();
if (Methods.hasMethod()) if (Methods.hasMethod())
{ {
try try
@@ -461,7 +462,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
} }
} }
super.setMoney(value, true); 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); 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 static final HandlerList handlers = new HandlerList();
private final Player player; private final Player player;
private final BigDecimal originalBalance;
private final BigDecimal balance; private final BigDecimal balance;
public UserBalanceUpdateEvent(Player player, BigDecimal balance) public UserBalanceUpdateEvent(Player player, BigDecimal originalBalance, BigDecimal balance)
{ {
this.player = player; this.player = player;
this.originalBalance = originalBalance;
this.balance = balance; this.balance = balance;
} }
@@ -39,4 +41,9 @@ public class UserBalanceUpdateEvent extends Event
{ {
return balance; return balance;
} }
public BigDecimal getOldBalance()
{
return originalBalance;
}
} }