public void giveMoney(final double value, final CommandSender initiator) { if (value == 0) { return; } setMoney(getMoney() + value); sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess))); if (initiator != null) { initiator.sendMessage( Util.format( "addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())); } }
public void payUser(final User reciever, final double value) throws Exception { if (value == 0) { return; } if (canAfford(value)) { setMoney(getMoney() - value); reciever.setMoney(reciever.getMoney() + value); sendMessage( Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName())); reciever.sendMessage( Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName())); } else { throw new Exception(Util.i18n("notEnoughMoney")); } }
@Override public void payUser(final User reciever, final BigDecimal value) throws ChargeException, MaxMoneyException { if (value.signum() == 0) { return; } if (canAfford(value)) { setMoney(getMoney().subtract(value)); reciever.setMoney(reciever.getMoney().add(value)); sendMessage( tl("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName())); reciever.sendMessage( tl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName())); } else { throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(value, ess))); } }
@Override public void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException { if (value.signum() == 0) { return; } setMoney(getMoney().add(value)); sendMessage(tl("addedToAccount", NumberUtil.displayCurrency(value, ess))); if (initiator != null) { initiator.sendMessage( tl( "addedToOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess))); } }
@Override public void takeMoney(final BigDecimal value, final CommandSource initiator) { if (value.signum() == 0) { return; } try { setMoney(getMoney().subtract(value)); } catch (MaxMoneyException ex) { ess.getLogger() .log( Level.WARNING, "Invalid call to takeMoney, total balance can't be more than the max-money limit.", ex); } sendMessage(tl("takenFromAccount", NumberUtil.displayCurrency(value, ess))); if (initiator != null) { initiator.sendMessage( tl( "takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess))); } }