From d335369efaed717fd4effa49f81b9c556341183e Mon Sep 17 00:00:00 2001 From: JRoy <10731363+JRoy@users.noreply.github.com> Date: Sun, 12 Apr 2026 13:02:11 -0700 Subject: [PATCH] Fix deposits rejected when account has negative balance Economy.add() delegated to setMoney() which checks minMoney and loan permission against the resulting balance. Both checks reject negative results even when the balance is improving from a deposit. Since deposits can only move the balance upward, route them directly to user.setMoney() bypassing the floor/loan checks. Withdrawals still go through setMoney() with full validation. Fixes #5606 --- .../main/java/com/earth2me/essentials/api/Economy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/api/Economy.java b/Essentials/src/main/java/com/earth2me/essentials/api/Economy.java index 8fdcfa5a16e..41e8261894e 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/api/Economy.java +++ b/Essentials/src/main/java/com/earth2me/essentials/api/Economy.java @@ -323,7 +323,13 @@ public static void add(final User user, final BigDecimal amount) throws NoLoanPe throw new IllegalArgumentException("Economy user cannot be null"); } final BigDecimal result = getMoneyExact(user).add(amount, MATH_CONTEXT); - setMoney(user, result); + // Deposits (positive amounts) always improve the balance, so minMoney and + // loan checks don't apply — they exist to prevent the balance from dropping. + if (amount.signum() <= 0) { + setMoney(user, result); + } else { + user.setMoney(result, UserBalanceUpdateEvent.Cause.API); + } Trade.log("API", "Add", "API", user.getName(), new Trade(amount, ess), null, null, null, result, ess); }