From 942d799c9c85d04872a6a96c84e94e53eed3731c Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 9 Jun 2021 21:51:51 +0200 Subject: [PATCH] Make "NaN" in placeholders translatable --- .../core/util/placeholders/PlaceholderRegistry.java | 7 ++++++- Core/src/main/resources/lang/messages_en.json | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) 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 86053a826..1015442df 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 @@ -178,7 +178,12 @@ public final class PlaceholderRegistry { this.createPlaceholder("currentplot_x", (player, plot) -> Integer.toString(plot.getId().getX())); this.createPlaceholder("currentplot_y", (player, plot) -> Integer.toString(plot.getId().getY())); this.createPlaceholder("currentplot_xy", (player, plot) -> plot.getId().toString()); - this.createPlaceholder("currentplot_rating", (player, plot) -> Double.toString(plot.getAverageRating())); + this.createPlaceholder("currentplot_rating", (player, plot) -> { + if (Double.isNaN(plot.getAverageRating())) { + return legacyComponent(TranslatableCaption.of("placeholder.nan"), player); + } + return Double.toString(plot.getAverageRating()); + }); this.createPlaceholder("currentplot_biome", (player, plot) -> plot.getBiomeSynchronous().toString()); } diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 06c740a9d..01e02e323 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -187,6 +187,7 @@ "core.prefix": "[P2] ", "core.enabled": " is now enabled.", "placeholder.hooked": "PlotSquared hooked into MVdWPlaceholderAPI", + "placeholder.nan": "Not a number", "reload.reloaded_configs": "Translations and world settings have been reloaded successfully.", "reload.reload_failed": "Failed to reload file configurations.", "desc.desc_set": "Plot description set.",