diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/TownyEconomyHandler.java b/Towny/src/main/java/com/palmergames/bukkit/towny/TownyEconomyHandler.java index b45a7fa2d8..d8e2b9ac6c 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/TownyEconomyHandler.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/TownyEconomyHandler.java @@ -45,7 +45,7 @@ public class TownyEconomyHandler { private static EconomyAdapter economy = null; private static EconomyProvider provider = null; private static String version = ""; - + private static final Executor ECONOMY_EXECUTOR = runnable -> { if (TownySettings.isEconomyAsync() && plugin.getScheduler().isTickThread()) plugin.getScheduler().runAsync(runnable); @@ -281,12 +281,11 @@ public static boolean subtract(String accountName, double amount, World world) { * @return true if successful */ public static boolean subtract(Account account, double amount) { - System.out.println("TownyEconomyHandler#subtract 1"); + if (!runPreChecks(Transaction.subtract(amount).paidBy(account).build())) { - System.out.println("TownyEconomyHandler#subtract 2"); return false; } - System.out.println("TownyEconomyHandler#subtract 3"); + return economy.subtract(account, amount); } @@ -316,7 +315,6 @@ public static boolean add(Account account, double amount) { return false; } - System.out.println("TownyEconomyHandler#add " + account.getName()); return economy.add(account, amount); } diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/db/TownyDatabaseHandler.java b/Towny/src/main/java/com/palmergames/bukkit/towny/db/TownyDatabaseHandler.java index d3f56b5c46..7fbf7d4018 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/db/TownyDatabaseHandler.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/db/TownyDatabaseHandler.java @@ -637,7 +637,6 @@ public void renameTown(Town town, String newName) throws AlreadyRegisteredExcept } } - UUID oldUUID = town.getUUID(); long oldregistration = town.getRegistered(); diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/object/EconomyAccount.java b/Towny/src/main/java/com/palmergames/bukkit/towny/object/EconomyAccount.java index 615a745f49..9cef22f4d7 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/object/EconomyAccount.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/object/EconomyAccount.java @@ -29,7 +29,6 @@ protected synchronized boolean addMoney(double amount) { @Override protected synchronized boolean subtractMoney(double amount) { - System.out.println("EconomyAccount#subtractMoney 1"); return TownyEconomyHandler.subtract(this, amount); } } diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/object/Government.java b/Towny/src/main/java/com/palmergames/bukkit/towny/object/Government.java index 25a68b09c7..568befac8e 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/object/Government.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/object/Government.java @@ -266,12 +266,9 @@ public final synchronized void depositToBank(Resident resident, int amount) thro if (!TownyEconomyHandler.isActive()) { throw new TownyException(Translation.of("msg_err_no_economy")); } - - System.out.println("Government#depositToBank 1"); if (!resident.getAccount().payTo(amount, this, "Deposit from " + resident.getName())) { throw new TownyException(Translation.of("msg_insuf_funds")); } - System.out.println("Government#depositToBank 1"); } @Override diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/Account.java b/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/Account.java index 91c9d3ea2b..e895217423 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/Account.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/Account.java @@ -142,7 +142,6 @@ public synchronized boolean withdraw(double amount, String reason) { return payToServer(amount, reason); BukkitTools.fireEvent(Transaction.subtract(amount).paidBy(this).asTownyTransactionEvent()); - System.out.println("Account#withdraw 1"); return true; } @@ -186,12 +185,11 @@ protected synchronized boolean payFromServer(double amount, String reason) { * @return boolean indicating success. */ public synchronized boolean payTo(double amount, Account collector, String reason) { - System.out.println("Account#payTo 1"); + if (amount > getHoldingBalance()) { - System.out.println("Account#payTo 2"); return false; } - System.out.println("Account#payTo 3"); + boolean success = withdraw(amount, reason) && collector.deposit(amount, reason); if (success) BukkitTools.fireEvent(Transaction.add(amount).paidBy(this).paidTo(collector).asTownyTransactionEvent()); diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/BankAccount.java b/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/BankAccount.java index 5f8c53fd56..7dfd78addb 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/BankAccount.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/object/economy/BankAccount.java @@ -82,7 +82,6 @@ protected synchronized boolean addMoney(double amount) { if (isBankrupt()) return removeDebt(amount); - System.out.println("BankAccount#addMoney 1"); // Otherwise continue like normal. return TownyEconomyHandler.add(this, amount); } diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/utils/MoneyUtil.java b/Towny/src/main/java/com/palmergames/bukkit/towny/utils/MoneyUtil.java index 35611cb944..24b42ec9cd 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/utils/MoneyUtil.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/utils/MoneyUtil.java @@ -75,9 +75,8 @@ public static void townWithdraw(Player player, Resident resident, Town town, int public static void townDeposit(Player player, Resident resident, Town town, Nation nation, int amount) { try { - System.out.println("MoneyUtil#townDeposit 1"); commonTests(amount, resident, town, player.getLocation(), false, false); - System.out.println("MoneyUtil#townDeposit 2"); + Transaction transaction = Transaction.deposit(amount).paidBy(resident).paidTo(town).build(); BukkitTools.ifCancelledThenThrow(new TownPreTransactionEvent(town, transaction)); @@ -160,10 +159,9 @@ private static void commonTests(int amount, Resident resident, Town town, Locati if (amount < 0) throw new TownyException(Translatable.of("msg_err_negative_money")); - System.out.println("MoneyUtil#commonTests 1"); if (!withdraw && !resident.getAccount().canPayFromHoldings(amount)) throw new TownyException(Translatable.of("msg_insuf_funds")); - System.out.println("MoneyUtil#commonTests 2"); + if (!nation && town.isRuined()) throw new TownyException(Translatable.of("msg_err_cannot_use_command_because_town_ruined"));