Update unsupported MiniMessage syntax

This commit is contained in:
Alexander Brandes 2023-06-22 19:55:36 +02:00
parent 9d43434e40
commit e2ba93dab9
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
2 changed files with 14 additions and 6 deletions

View File

@ -28,7 +28,7 @@ import java.nio.file.Paths;
import java.util.stream.Stream; 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 * MiniMessage changed the syntax between major releases. To warrant a smooth upgrade, we attempt to replace any occurrences
* while loading PlotSquared. * while loading PlotSquared.
* *
@ -38,14 +38,22 @@ import java.util.stream.Stream;
public class TranslationUpdateManager { public class TranslationUpdateManager {
public static void upgradeTranslationFile() throws IOException { public static void upgradeTranslationFile() throws IOException {
String searchText = "suggest_command"; String suggestCommand = "suggest_command";
String replacementText = "run_command"; String suggestCommandReplacement = "run_command";
String minHeight = "minHeight";
String minheightReplacement = "minheight";
String maxHeight = "maxHeight";
String maxheightReplacement = "maxheight";
try (Stream<Path> paths = Files.walk(Paths.get(PlotSquared.platform().getDirectory().toPath().resolve("lang").toUri()))) { try (Stream<Path> paths = Files.walk(Paths.get(PlotSquared.platform().getDirectory().toPath().resolve("lang").toUri()))) {
paths paths
.filter(Files::isRegularFile) .filter(Files::isRegularFile)
.filter(p -> p.getFileName().toString().matches("messages_[a-z]{2}\\.json")) .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);
});
} }
} }

View File

@ -657,9 +657,9 @@ public abstract class PlotArea implements ComponentLike {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("height.height_limit"), TranslatableCaption.of("height.height_limit"),
TagResolver.builder() TagResolver.builder()
.tag("minHeight", Tag.inserting(Component.text(minBuildHeight))) .tag("minheight", Tag.inserting(Component.text(minBuildHeight)))
.tag( .tag(
"maxHeight", "maxheight",
Tag.inserting(Component.text(maxBuildHeight)) Tag.inserting(Component.text(maxBuildHeight))
).build() ).build()
); );