Merge pull request #149 from AuthMe-Team/master

Fixed configuration file (VERY IMPORTANT)
This commit is contained in:
Alexandre Vanhecke 2015-07-25 00:23:57 +02:00
commit 97ff672fa2
3 changed files with 23 additions and 17 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();
@ -569,6 +570,8 @@ public final class Settings extends YamlConfiguration {
}
if (contains("Performances.useMultiThreading"))
set("Performances.useMultiThreading", null);
if (contains("Performances"))
set("Performances", null);
if (!contains("Email.emailWhitelisted")) {
set("Email.emailWhitelisted", new ArrayList<String>());
changes = true;
@ -683,7 +686,7 @@ public final class Settings extends YamlConfiguration {
public final void reload() {
load();
loadDefaults(file);
loadDefaults(file.getName());
}
/**
@ -715,12 +718,14 @@ public final class Settings extends YamlConfiguration {
* @param filename
* The filename to open
*/
public final void loadDefaults(File file) {
if (!file.exists())
return;
setDefaults(YamlConfiguration.loadConfiguration(file));
}
@SuppressWarnings("deprecation")
public final void loadDefaults(String filename) {
InputStream stream = plugin.getResource(filename);
if (stream == null)
return;
setDefaults(YamlConfiguration.loadConfiguration(stream));
}
/**
* Saves current configuration (plus defaults) to disk.

View File

@ -1,7 +1,7 @@
DataSource:
# Can be set to : file, sqlite, mysql
# Can be set to: sqlite, mysql
backend: sqlite
# Do we need to cache all query?
# Enable database caching
caching: true
# Database location
mySQLHost: 127.0.0.1
@ -385,10 +385,6 @@ Hooks:
useEssentialsMotd: false
# Do we need to cache custom Attributes ?
customAttributes: false
Performances:
# HIGHLY recommended to use this! This will increase database performance
# Default is true, change it to false if you experience issues
useMultiThreading: true
Purge:
# On Enable , does AuthMe need to purge automatically old accounts unused ?
useAutoPurge: false