use of net.ess3.api.Economy in project Essentials by EssentialsX.
the class User method setMoney.
public void setMoney(final BigDecimal value, final UserBalanceUpdateEvent.Cause cause) throws MaxMoneyException {
if (ess.getSettings().isEcoDisabled()) {
if (ess.getSettings().isDebug()) {
ess.getLogger().info("Internal economy functions disabled, aborting balance change.");
}
return;
}
final BigDecimal oldBalance = _getMoney();
final UserBalanceUpdateEvent updateEvent = new UserBalanceUpdateEvent(this.getBase(), oldBalance, value, cause);
ess.getServer().getPluginManager().callEvent(updateEvent);
final BigDecimal newBalance = updateEvent.getNewBalance();
final EconomyLayer layer = EconomyLayers.getSelectedLayer();
if (layer != null && (layer.hasAccount(getBase()) || layer.createPlayerAccount(getBase()))) {
layer.set(getBase(), newBalance);
}
super.setMoney(newBalance, true);
Trade.log("Update", "Set", "API", getName(), new Trade(newBalance, ess), null, null, null, newBalance, ess);
}
Aggregations