Hotfix: it was shit, sorry

This commit is contained in:
Gabriele C 2015-07-25 00:08:29 +02:00
parent a614d3e554
commit a7a4a511e7
2 changed files with 19 additions and 11 deletions

View File

@ -1,9 +1,12 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.io.InputStream;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
public class Messages extends CustomConfiguration {
@ -24,11 +27,13 @@ public class Messages extends CustomConfiguration {
* @param filename
* The filename to open
*/
@SuppressWarnings("deprecation")
public final void loadDefaults(File file) {
if (!file.exists())
InputStream stream = AuthMe.getInstance().getResource(file.getName());
if (stream == null)
return;
setDefaults(YamlConfiguration.loadConfiguration(file));
setDefaults(YamlConfiguration.loadConfiguration(stream));
}
/**

View File

@ -7,6 +7,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -102,7 +103,7 @@ public final class Settings extends YamlConfiguration {
if (exists()) {
load();
} else {
loadDefaults(file);
loadDefaults(file.getName());
load();
}
configFile = (YamlConfiguration) plugin.getConfig();
@ -685,7 +686,7 @@ public final class Settings extends YamlConfiguration {
public final void reload() {
load();
loadDefaults(file);
loadDefaults(file.getName());
}
/**
@ -717,11 +718,13 @@ public final class Settings extends YamlConfiguration {
* @param filename
* The filename to open
*/
public final void loadDefaults(File file) {
if (!file.exists())
@SuppressWarnings("deprecation")
public final void loadDefaults(String filename) {
InputStream stream = plugin.getResource(filename);
if (stream == null)
return;
setDefaults(YamlConfiguration.loadConfiguration(file));
setDefaults(YamlConfiguration.loadConfiguration(stream));
}
/**