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:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user