fix: custom lang file not being copied over
This commit is contained in:
parent
f63c82a01f
commit
5fbcdf5de2
1 changed files with 8 additions and 5 deletions
|
@ -1,11 +1,11 @@
|
||||||
package net.artelnatif.nicko.i18n;
|
package net.artelnatif.nicko.i18n;
|
||||||
|
|
||||||
import com.github.jsixface.YamlConfig;
|
import com.github.jsixface.YamlConfig;
|
||||||
|
import de.studiocode.invui.util.IOUtils;
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
import net.artelnatif.nicko.NickoBukkit;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class LocaleFileManager {
|
public class LocaleFileManager {
|
||||||
private final Yaml yaml = new Yaml();
|
private final Yaml yaml = new Yaml();
|
||||||
|
@ -25,15 +25,18 @@ public class LocaleFileManager {
|
||||||
public boolean dumpFromLocale(Locale locale) {
|
public boolean dumpFromLocale(Locale locale) {
|
||||||
if (locale == Locale.CUSTOM) return true;
|
if (locale == Locale.CUSTOM) return true;
|
||||||
if (file.exists()) return true;
|
if (file.exists()) return true;
|
||||||
final HashMap<String, String> values = yaml.load(this.getClass().getClassLoader().getResourceAsStream(locale.getCode() + ".yml"));
|
final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(locale.getCode() + ".yml");
|
||||||
try {
|
try {
|
||||||
|
if (folder.mkdirs()) {
|
||||||
if (file.createNewFile()) {
|
if (file.createNewFile()) {
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
try (FileOutputStream outputStream = new FileOutputStream(file)) {
|
||||||
yaml.dump(values, writer);
|
IOUtils.copy(inputStream, outputStream, 8192);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue