mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-07-03 08:15:42 +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.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class FileLanguage implements FileData {
|
public class FileLanguage implements FileData {
|
||||||
private final YamlConfiguration config = new YamlConfiguration();
|
private final YamlConfiguration config = new YamlConfiguration();
|
||||||
@ -57,12 +58,12 @@ public class FileLanguage implements FileData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final String[] defaultLangs = {
|
private final String[] defaultLangs = {
|
||||||
|
"en.yml", // English - KEEP AS FIRST IN THE LIST
|
||||||
"chs.yml", //Chinese Simplified (OasisAkari)
|
"chs.yml", //Chinese Simplified (OasisAkari)
|
||||||
"cht.yml", //Chinese (OasisAkari & kamiya10)
|
"cht.yml", //Chinese (OasisAkari & kamiya10)
|
||||||
"cs.yml", //Czech (Lewisparkle)
|
"cs.yml", //Czech (Lewisparkle)
|
||||||
"da.yml", //Danish (Janbchr)
|
"da.yml", //Danish (Janbchr)
|
||||||
"de.yml", //German (IBimsDaNico#8690)
|
"de.yml", //German (IBimsDaNico#8690)
|
||||||
"en.yml",
|
|
||||||
"es.yml", //Spanish (emgv)
|
"es.yml", //Spanish (emgv)
|
||||||
"fr.yml", //French (At0micA55 & Mrflo67)
|
"fr.yml", //French (At0micA55 & Mrflo67)
|
||||||
"he.yml", //Hebrew (thefourcraft)
|
"he.yml", //Hebrew (thefourcraft)
|
||||||
@ -77,11 +78,14 @@ public class FileLanguage implements FileData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void generateDefaults() {
|
private void generateDefaults() {
|
||||||
//Generate all language files
|
// Generate all language files
|
||||||
for (String yaml : defaultLangs) {
|
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]))
|
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)
|
if (in == null)
|
||||||
in = plugin().getResource(fileNameDef.replace(File.separator, "/"));
|
in = plugin().getResource(fileNameDef.replace(File.separator, "/"));
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in)));
|
config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(in, StandardCharsets.UTF_8)));
|
||||||
config.options().copyDefaults(true);
|
config.options().copyDefaults(true);
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user