From bf20b0dd799e2c29d5edaf529f5d658475228c9c Mon Sep 17 00:00:00 2001 From: N0tMyFaultOG Date: Sun, 27 Dec 2020 19:16:26 +0100 Subject: [PATCH] Beautify placeholder output for '*' permission --- .../core/util/placeholders/PlaceholderRegistry.java | 10 ++++++++-- Core/src/main/resources/lang/messages_en.json | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java index 71b16cf84..5a5b12c3a 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java @@ -78,7 +78,12 @@ public final class PlaceholderRegistry { }); this.createPlaceholder("currentplot_world", player -> player.getLocation().getWorldName()); this.createPlaceholder("has_plot", player -> player.getPlotCount() > 0 ? "true" : "false"); - this.createPlaceholder("allowed_plot_count", player -> Integer.toString(player.getAllowedPlots())); + this.createPlaceholder("allowed_plot_count", (player) -> { + if (player.getAllowedPlots() >= Integer.MAX_VALUE) { // Beautifies cases with '*' permission + return String.valueOf(TranslatableCaption.of("info.infinite")); + } + return Integer.toString(player.getAllowedPlots()); + }); this.createPlaceholder("plot_count", player -> Integer.toString(player.getPlotCount())); this.createPlaceholder("currentplot_alias", (player, plot) -> { if (plot.getAlias() == null) { @@ -94,7 +99,8 @@ public final class PlaceholderRegistry { try { return PlayerManager.getName(plotOwner, false); - } catch (final Exception ignored) {} + } catch (final Exception ignored) { + } return String.valueOf(TranslatableCaption.of("info.unknown")); }); diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 95f55f98b..36bdc1f42 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -377,6 +377,7 @@ "info.unknown": "Unknown", "info.server": "Server", "info.everyone": "Everyone", + "info.infinite": "Infinite", "info.plot_unowned": "The current plot must have an owner to perform this action.", "info.plot_info_unclaimed": "Plot is not yet claimed.", "info.plot_info_header": "--------- INFO ---------",