From e2ba93dab9b7ccbb46686f0f7d43ff9074d0e1cd Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Thu, 22 Jun 2023 19:55:36 +0200 Subject: [PATCH] Update unsupported MiniMessage syntax --- .../bukkit/util/TranslationUpdateManager.java | 16 ++++++++++++---- .../java/com/plotsquared/core/plot/PlotArea.java | 4 ++-- 2 files changed, 14 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 71466eb8c..0c25f5bf7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/TranslationUpdateManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/TranslationUpdateManager.java @@ -28,7 +28,7 @@ import java.nio.file.Paths; import java.util.stream.Stream; /** - * This is a helper class which replaces occurrences of 'suggest_command' with 'run_command' in messages_%.json. + * This is a helper class which replaces older syntax no longer supported by MiniMessage with replacements in messages_%.json. * MiniMessage changed the syntax between major releases. To warrant a smooth upgrade, we attempt to replace any occurrences * while loading PlotSquared. * @@ -38,14 +38,22 @@ import java.util.stream.Stream; public class TranslationUpdateManager { public static void upgradeTranslationFile() throws IOException { - String searchText = "suggest_command"; - String replacementText = "run_command"; + String suggestCommand = "suggest_command"; + String suggestCommandReplacement = "run_command"; + String minHeight = "minHeight"; + String minheightReplacement = "minheight"; + String maxHeight = "maxHeight"; + String maxheightReplacement = "maxheight"; try (Stream paths = Files.walk(Paths.get(PlotSquared.platform().getDirectory().toPath().resolve("lang").toUri()))) { paths .filter(Files::isRegularFile) .filter(p -> p.getFileName().toString().matches("messages_[a-z]{2}\\.json")) - .forEach(p -> replaceInFile(p, searchText, replacementText)); + .forEach(p -> { + replaceInFile(p, suggestCommand, suggestCommandReplacement); + replaceInFile(p, minHeight, minheightReplacement); + replaceInFile(p, maxHeight, maxheightReplacement); + }); } } diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index 97535efb3..aa24e527b 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -657,9 +657,9 @@ public abstract class PlotArea implements ComponentLike { player.sendMessage( TranslatableCaption.of("height.height_limit"), TagResolver.builder() - .tag("minHeight", Tag.inserting(Component.text(minBuildHeight))) + .tag("minheight", Tag.inserting(Component.text(minBuildHeight))) .tag( - "maxHeight", + "maxheight", Tag.inserting(Component.text(maxBuildHeight)) ).build() );