mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-07-01 23:36:18 +00:00
Ensure that the English file always is available as a backup (#178)
This commit is contained in:
parent
9042fbf6d1
commit
044054d594
@ -7,6 +7,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class FileLanguage implements FileData {
|
||||
private final YamlConfiguration config = new YamlConfiguration();
|
||||
@ -57,12 +58,12 @@ public class FileLanguage implements FileData {
|
||||
}
|
||||
|
||||
private final String[] defaultLangs = {
|
||||
"en.yml", // English - KEEP AS FIRST IN THE LIST
|
||||
"chs.yml", //Chinese Simplified (OasisAkari)
|
||||
"cht.yml", //Chinese (OasisAkari & kamiya10)
|
||||
"cs.yml", //Czech (Lewisparkle)
|
||||
"da.yml", //Danish (Janbchr)
|
||||
"de.yml", //German (IBimsDaNico#8690)
|
||||
"en.yml",
|
||||
"es.yml", //Spanish (emgv)
|
||||
"fr.yml", //French (At0micA55 & Mrflo67)
|
||||
"he.yml", //Hebrew (thefourcraft)
|
||||
@ -77,11 +78,14 @@ public class FileLanguage implements FileData {
|
||||
};
|
||||
|
||||
private void generateDefaults() {
|
||||
//Generate all language files
|
||||
// Generate all language files
|
||||
for (String yaml : defaultLangs) {
|
||||
generateDefaultConfig(yaml, yaml); //Generate its own defaults
|
||||
generateDefaultConfig(yaml, yaml); // Generate defaults of this language
|
||||
|
||||
// Not english, make sure all options are present
|
||||
if (!yaml.equals(defaultLangs[0]))
|
||||
generateDefaultConfig(yaml, defaultLangs[0]); //Generate the english defaults (incase)
|
||||
// Generate the english defaults (in case some options are missing)
|
||||
generateDefaultConfig(yaml, defaultLangs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +102,7 @@ public class FileLanguage implements FileData {
|
||||
if (in == null)
|
||||
in = plugin().getResource(fileNameDef.replace(File.separator, "/"));
|
||||
if (in != null) {
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in)));
|
||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in, StandardCharsets.UTF_8)));
|
||||
config.options().copyDefaults(true);
|
||||
in.close();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user