From e4613cfc6260b23c4dc776c53bac6ba10aab4273 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Fri, 12 Jan 2024 09:35:11 +0100 Subject: [PATCH] Fix minimessage tag resolver in list command (#4290) fix: update resolver tag names for list command --- .../bukkit/util/TranslationUpdateManager.java | 11 +++++++++++ .../java/com/plotsquared/core/command/ListCmd.java | 6 +++--- Core/src/main/resources/lang/messages_en.json | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/TranslationUpdateManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/TranslationUpdateManager.java index 9d7109e5d..04559618f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/TranslationUpdateManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/TranslationUpdateManager.java @@ -55,6 +55,14 @@ public class TranslationUpdateManager { String userMove = "userMove"; String userMoveReplacement = "user_move"; + // tag opening / closing characters are important, as the locale keys exist as well, which should not be replaced + String listInfoUnknown = ""; + String listInfoUnknownReplacement = ""; + String listInfoServer = ""; + String listInfoServerReplacement = ""; + String listInfoEveryone = ""; + String listInfoEveryoneReplacement = ""; + try (Stream paths = Files.walk(Paths.get(PlotSquared.platform().getDirectory().toPath().resolve("lang").toUri()))) { paths .filter(Files::isRegularFile) @@ -68,6 +76,9 @@ public class TranslationUpdateManager { replaceInFile(p, minimumRadius, minimumRadiusReplacement); replaceInFile(p, maximumMoves, maximumMovesReplacement); replaceInFile(p, userMove, userMoveReplacement); + replaceInFile(p, listInfoUnknown, listInfoUnknownReplacement); + replaceInFile(p, listInfoServer, listInfoServerReplacement); + replaceInFile(p, listInfoEveryone, listInfoEveryoneReplacement); }); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java index de7378c2d..144380447 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -465,7 +465,7 @@ public class ListCmd extends SubCommand { TextComponent.Builder builder = Component.text(); if (plot.getFlag(ServerPlotFlag.class)) { TagResolver serverResolver = TagResolver.resolver( - "info.server", + "server", Tag.inserting(TranslatableCaption.of("info.server").toComponent(player)) ); builder.append(MINI_MESSAGE.deserialize(server, serverResolver)); @@ -483,13 +483,13 @@ public class ListCmd extends SubCommand { builder.append(MINI_MESSAGE.deserialize(online, resolver)); } else if (uuidMapping.username().equalsIgnoreCase("unknown")) { TagResolver unknownResolver = TagResolver.resolver( - "info.unknown", + "unknown", Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player)) ); builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver)); } else if (uuidMapping.uuid().equals(DBFunc.EVERYONE)) { TagResolver everyoneResolver = TagResolver.resolver( - "info.everyone", + "everyone", Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player)) ); builder.append(MINI_MESSAGE.deserialize(everyone, everyoneResolver)); diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 278efc25e..1887fbd7e 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -381,9 +381,9 @@ "info.plot_list_default": "", "info.plot_list_player_online": "Online'>", "info.plot_list_player_offline": "Offline'>", - "info.plot_list_player_unknown": "The owner of this plot is unknown'>", - "info.plot_list_player_server": "The plot is owned by the server'>", - "info.plot_list_player_everyone": "The plot is owned by everyone'>", + "info.plot_list_player_unknown": "The owner of this plot is unknown'>", + "info.plot_list_player_server": "The plot is owned by the server'>", + "info.plot_list_player_everyone": "The plot is owned by everyone'>", "info.area_info_format": "
\nName: \nType: \nTerrain: \nUsage: %\nClaimed: \nClusters: \nRegion: \nGenerator: \n