mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Fixes #3919
This commit is contained in:
parent
36e5f36660
commit
a12490c3eb
@ -51,6 +51,7 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitWorld;
|
||||
import com.plotsquared.bukkit.util.SetGenCB;
|
||||
import com.plotsquared.bukkit.util.UpdateUtility;
|
||||
import com.plotsquared.bukkit.util.TranslationUpdateManager;
|
||||
import com.plotsquared.bukkit.util.task.BukkitTaskManager;
|
||||
import com.plotsquared.bukkit.util.task.PaperTimeConverter;
|
||||
import com.plotsquared.bukkit.util.task.SpigotTimeConverter;
|
||||
@ -138,6 +139,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.incendo.serverlib.ServerLib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -291,6 +293,12 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
);
|
||||
this.injector.injectMembers(this);
|
||||
|
||||
try {
|
||||
this.injector.getInstance(TranslationUpdateManager.class).upgradeTranslationFile();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
this.serverLocale = Locale.forLanguageTag(Settings.Enabled_Components.DEFAULT_LOCALE);
|
||||
|
||||
if (PremiumVerification.isPremium() && Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* PlotSquared, a land and world management plugin for Minecraft.
|
||||
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
||||
* Copyright (C) IntellectualSites team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.intellectualsites.annotations.NotPublic;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
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.
|
||||
* MiniMessage changed the syntax between major releases. To warrant a smooth upgrade, we attempt to replace any occurrences
|
||||
* while loading PlotSquared.
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
@NotPublic
|
||||
public class TranslationUpdateManager {
|
||||
|
||||
public static void upgradeTranslationFile() throws IOException {
|
||||
String searchText = "suggest_command";
|
||||
String replacementText = "run_command";
|
||||
|
||||
try (Stream<Path> 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));
|
||||
}
|
||||
}
|
||||
|
||||
private static void replaceInFile(Path path, String searchText, String replacementText) {
|
||||
try {
|
||||
String content = Files.readString(path);
|
||||
if (content.contains(searchText)) {
|
||||
content = content.replaceAll(searchText, replacementText);
|
||||
Files.writeString(path, content);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -683,8 +683,8 @@ public final class FlagCommand extends Command {
|
||||
TranslatableCaption.of("flag.flag_info_example"),
|
||||
TagResolver.builder()
|
||||
.tag("command", Tag.preProcessParsed("/plot flag set"))
|
||||
.tag("flag", Tag.inserting(Component.text(plotFlag.getName())))
|
||||
.tag("value", Tag.inserting(Component.text(plotFlag.getExample())))
|
||||
.tag("flag", Tag.preProcessParsed(plotFlag.getName()))
|
||||
.tag("value", Tag.preProcessParsed(plotFlag.getExample()))
|
||||
.build()
|
||||
);
|
||||
// Default value
|
||||
|
@ -514,7 +514,7 @@
|
||||
"flag.flag_info_name": "<gray>Name: <gold><flag></gold></gray>",
|
||||
"flag.flag_info_category": "<gray>Category: </gray><gold><value></gold>",
|
||||
"flag.flag_info_description": "<gray>Description: </gray>",
|
||||
"flag.flag_info_example": "<gray>Example: <click:suggest_command:'<command> <flag> <value>'><gold><command> <flag> <value></gold></click></gray>",
|
||||
"flag.flag_info_example": "<gray>Example: <click:run_command:'<command> <flag> <value>'><gold><command> <flag> <value></gold></click></gray>",
|
||||
"flag.flag_info_default_value": "<gray>Default Value: <value></gray>",
|
||||
"flags.flag_category_string": "<gray>String Flags</gray>",
|
||||
"flags.flag_category_integers": "<gray>Integer Flags</gray>",
|
||||
|
Loading…
Reference in New Issue
Block a user