Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ public void run(final Server server, final CommandSource sender, final String co

switch (cmd) {
case GIVE: {
player.giveMoney(userAmount, sender, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
final BigDecimal serverMaxBal = ess.getSettings().getMaxMoney();
final BigDecimal postTransactionBal = player.getMoney().add(userAmount);
if (postTransactionBal.compareTo(serverMaxBal) > 0) {
ess.showError(sender, new TranslatableException("maxMoney", AdventureUtil.parsed(NumberUtil.displayCurrency(serverMaxBal, ess))), commandLabel);
} else {
player.giveMoney(userAmount, sender, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
}
break;
}
case TAKE: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void run(final Server server, final User user, final String commandLabel,
user.sendTl("payOffline");
return;
}

if (!player.isAcceptingPay() || (ess.getSettings().isPayExcludesIgnoreList() && player.isIgnoredPlayer(user))) {
user.sendTl("notAcceptingPay", player.getDisplayName());
return;
Expand All @@ -80,6 +79,14 @@ public void run(final Server server, final User user, final String commandLabel,
user.getConfirmingPayments().put(player, amount);
return;
}
final BigDecimal serverMaxBal = ess.getSettings().getMaxMoney();
final BigDecimal postTransactionBal = player.getMoney().add(amount);
if (postTransactionBal.compareTo(serverMaxBal) > 0) {
if (!args[0].equals("*")) {
user.sendMessage("§c" + player.getDisplayName() + " would surpass the server's maximum balance limit!");
}
return;
}
user.payUser(player, amount, UserBalanceUpdateEvent.Cause.COMMAND_PAY);
user.getConfirmingPayments().remove(player);
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), user.getMoney(), ess);
Expand Down