From 68eb5cd74f0734a24a6879fc0cdafb5979acc931 Mon Sep 17 00:00:00 2001 From: "Patrick \"IPat\" Hein" Date: Wed, 12 May 2021 19:00:14 +0200 Subject: [PATCH] Replaced economy supported (Vault) check within cost condition with a pre-eliminating if-guard (#3014) --- .../src/main/java/com/plotsquared/core/command/Auto.java | 9 +++++---- .../main/java/com/plotsquared/core/command/Claim.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java index 4284a9748..5780a817a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -312,15 +312,16 @@ public class Auto extends SubCommand { player.getPlotCount(plotarea.getWorldName())); cost = (size_x * size_z) * cost; if (cost > 0d) { - if (!force && this.econHandler.getMoney(player) < cost && this.econHandler.isSupported()) { + if (!this.econHandler.isSupported()) { + player.sendMessage(TranslatableCaption.of("economy.vault_not_found")); + return false; + } + if (!force && this.econHandler.getMoney(player) < cost) { player.sendMessage( TranslatableCaption.of("economy.cannot_afford_plot"), Template.of("money", this.econHandler.format(cost)), Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) ); - } else { - player.sendMessage(TranslatableCaption.of("economy.vault_not_found")); - return false; } this.econHandler.withdrawMoney(player, cost); player.sendMessage( diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index 8e286eb51..f2816400b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -151,15 +151,16 @@ public class Claim extends SubCommand { PlotExpression costExr = area.getPrices().get("claim"); double cost = costExr.evaluate(currentPlots); if (cost > 0d) { - if (this.econHandler.getMoney(player) < cost && this.econHandler.isSupported()) { + if (!this.econHandler.isSupported()) { + player.sendMessage(TranslatableCaption.of("economy.vault_not_found")); + return false; + } + if (this.econHandler.getMoney(player) < cost) { player.sendMessage( TranslatableCaption.of("economy.cannot_afford_plot"), Template.of("money", this.econHandler.format(cost)), Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) ); - } else { - player.sendMessage(TranslatableCaption.of("economy.vault_not_found")); - return false; } this.econHandler.withdrawMoney(player, cost); player.sendMessage(