From 0ea615ab91402e4e283fb907799bea896162f4c4 Mon Sep 17 00:00:00 2001 From: LlmDl Date: Sat, 26 Oct 2024 12:28:51 -0500 Subject: [PATCH] Remove debug messages --- .../com/palmergames/bukkit/towny/TownyEconomyHandler.java | 8 +++----- .../palmergames/bukkit/towny/db/TownyDatabaseHandler.java | 1 - .../palmergames/bukkit/towny/object/EconomyAccount.java | 1 - .../com/palmergames/bukkit/towny/object/Government.java | 3 --- .../palmergames/bukkit/towny/object/economy/Account.java | 6 ++---- .../bukkit/towny/object/economy/BankAccount.java | 1 - .../com/palmergames/bukkit/towny/utils/MoneyUtil.java | 6 ++---- 7 files changed, 7 insertions(+), 19 deletions(-) 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 b45a7fa2d80..d8e2b9ac6ce 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 d3f56b5c46e..7fbf7d40182 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 615a745f49f..9cef22f4d78 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 25a68b09c75..568befac8e9 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 91c9d3ea2be..e895217423b 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 5f8c53fd567..7dfd78addbd 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 35611cb9449..24b42ec9cdc 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"));