mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-15 21:26:04 -05:00
Fix Missing No issue when upgrading messages
This commit is contained in:
1 parent
bc9d7e7b65
commit
021488c19f
3 files changed
+20
-2
No files matched your search
@@ -91,6 +91,4 @@ public class CommandContainer {
|
||||
return MsgUtil.getMessage("command.feature-not-enabled", null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import org.maxgamer.quickshop.util.JsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -48,6 +49,16 @@ public class HumanReadableJsonConfiguration extends JsonConfiguration {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public static HumanReadableJsonConfiguration loadConfiguration(@NotNull InputStreamReader inputStreamReader) {
|
||||
HumanReadableJsonConfiguration configuration = new HumanReadableJsonConfiguration();
|
||||
try {
|
||||
configuration.load(inputStreamReader);
|
||||
} catch (IOException | InvalidConfigurationException exception) {
|
||||
logger.log(Level.SEVERE, "Cannot load original language file", exception);
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String saveToString() {
|
||||
return JsonUtil.getHumanReadableGson().toJson(SerializationHelper.serialize(this.getValues(false)));
|
||||
|
||||
@@ -80,6 +80,7 @@ public class MsgUtil {
|
||||
@Getter
|
||||
private static YamlConfiguration potioni18n;
|
||||
private static JsonConfiguration builtInLang;
|
||||
private static JsonConfiguration builtInOriginalLang;
|
||||
|
||||
private static DecimalFormat processFormat() {
|
||||
try {
|
||||
@@ -288,6 +289,11 @@ public class MsgUtil {
|
||||
Util.debugLog("Cannot load default built-in language file: " + ioException.getMessage());
|
||||
}
|
||||
builtInLang = HumanReadableJsonConfiguration.loadConfiguration(buildInLangFile);
|
||||
try (InputStreamReader inputStreamReader = new InputStreamReader(Objects.requireNonNull(plugin.getResource("lang-original/messages.json")))) {
|
||||
builtInOriginalLang = HumanReadableJsonConfiguration.loadConfiguration(inputStreamReader);
|
||||
} catch (IOException | NullPointerException exception) {
|
||||
plugin.getLogger().log(Level.WARNING, "Cannot to load built-in original messages, some phrases may missing when upgrading", exception);
|
||||
}
|
||||
//Check the i18n language name and backup
|
||||
if (StringUtils.isEmpty(messagei18n.getString("language-name"))) {
|
||||
setAndUpdate("language-name");
|
||||
@@ -1472,6 +1478,9 @@ public class MsgUtil {
|
||||
if (builtInLang != null) {
|
||||
alt = builtInLang.get(path);
|
||||
}
|
||||
if (alt == null && builtInOriginalLang != null) {
|
||||
alt = builtInOriginalLang.get(path);
|
||||
}
|
||||
if (alt == null) {
|
||||
messagei18n.set(path, "Missing no: " + path);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user