From a990205d41704dc5a0f7993c64661db3ebc678f8 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 7 May 2021 01:53:18 +0200 Subject: [PATCH] Fix empty templates when vault not found --- Core/src/main/java/com/plotsquared/core/command/Auto.java | 6 ++++-- Core/src/main/java/com/plotsquared/core/command/Buy.java | 2 +- Core/src/main/java/com/plotsquared/core/command/Claim.java | 4 +++- Core/src/main/resources/lang/messages_en.json | 1 + 4 files changed, 9 insertions(+), 4 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 d81eba3e3..217db445f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -312,13 +312,15 @@ 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) { + if (!force && this.econHandler.getMoney(player) < cost && this.econHandler.isSupported()) { 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))) ); - return true; + } 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/Buy.java b/Core/src/main/java/com/plotsquared/core/command/Buy.java index 3bc1efc8b..bda0c4a18 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Buy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java @@ -98,7 +98,7 @@ public class Buy extends Command { throw new CommandException(TranslatableCaption.of("economy.not_for_sale")); } checkTrue( - this.econHandler.getMoney(player) >= price, + this.econHandler.getMoney(player) >= price && this.econHandler.isSupported(), TranslatableCaption.of("economy.cannot_afford_plot"), Template.of("money", this.econHandler.format(price)), Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) 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 6bfc6d325..b41a3548d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -151,12 +151,14 @@ 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) { + if (this.econHandler.getMoney(player) < cost && this.econHandler.isSupported()) { 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); diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index edfd47721..1261db944 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -103,6 +103,7 @@ "tutorial.rate_this": "Rate this plot!", "tutorial.comment_this": "Leave some feedback on this plot: .", "economy.econ_disabled": "Economy is not enabled.", + "economy.vault_not_found": "Vault is not installed. No Vault-like economy service can be provided.", "economy.cannot_afford_plot": "You cannot afford to buy this plot. It costs . You have .", "economy.not_for_sale": "This plot is not for sale.", "economy.cannot_buy_own": "You cannot buy your own plot.",