From b37ad79e506c6f6831889a8f68ea7e45a4f71cb8 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 7 May 2021 09:59:17 +0200 Subject: [PATCH] Beautify empty `/plot caps` output Also strip prefix from empty plot description --- Core/src/main/java/com/plotsquared/core/command/Buy.java | 5 ++++- Core/src/main/java/com/plotsquared/core/command/Caps.java | 3 ++- Core/src/main/java/com/plotsquared/core/command/Help.java | 2 +- Core/src/main/resources/lang/messages_en.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) 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 bda0c4a18..feeb43954 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Buy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java @@ -97,8 +97,11 @@ public class Buy extends Command { if (price <= 0) { throw new CommandException(TranslatableCaption.of("economy.not_for_sale")); } + checkTrue(this.econHandler.isSupported(), + TranslatableCaption.of("economy.vault_not_found") + ); checkTrue( - this.econHandler.getMoney(player) >= price && this.econHandler.isSupported(), + this.econHandler.getMoney(player) >= price, 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/Caps.java b/Core/src/main/java/com/plotsquared/core/command/Caps.java index 32c856f6a..4b7ad62af 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Caps.java +++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java @@ -89,11 +89,12 @@ public class Caps extends SubCommand { final int current = countedEntities[type]; final int max = plot.getFlag(capFlag); final String percentage = String.format("%.1f", 100 * ((float) current / max)); + String maxBeautified = max >= Integer.MAX_VALUE ? TranslatableCaption.of("info.infinite").getComponent(player) : String.valueOf(max); player.sendMessage( TranslatableCaption.of("info.plot_caps_format"), Template.of("cap", name), Template.of("current", String.valueOf(current)), - Template.of("limit", String.valueOf(max)), + Template.of("limit", maxBeautified), Template.of("percentage", percentage) ); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Help.java b/Core/src/main/java/com/plotsquared/core/command/Help.java index 63bbd0341..e59fc2742 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Help.java +++ b/Core/src/main/java/com/plotsquared/core/command/Help.java @@ -42,7 +42,7 @@ import java.util.concurrent.CompletableFuture; @CommandDeclaration(command = "help", aliases = "?", category = CommandCategory.INFO, - usage = "help [category|#]", + usage = "help [category | #]", permission = "plots.use") public class Help extends Command { diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 1261db944..b09667603 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -338,7 +338,7 @@ "info.plot_info_creationdate": "Creation: ", "info.plot_user_list": "", "info.plot_flag_list": ": ", - "info.plot_no_description": "No description set.", + "info.plot_no_description": "No description set.", "info.plot_caps_header": "--------- CAPS ---------", "info.plot_caps_format": "- Cap Type: | Status: / (%)", "info.plot_list_item": ">\">[]> \"> - ",