mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-09 01:48:15 +01:00
You can now access the old balance during the UserBalanceUpdateEvent Event
This commit is contained in:
parent
ee986768ce
commit
28ec7c2d80
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user