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; package fr.xephi.authme.settings;
import java.io.File; import java.io.File;
import java.io.InputStream;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
public class Messages extends CustomConfiguration { public class Messages extends CustomConfiguration {
@ -24,11 +27,13 @@ public class Messages extends CustomConfiguration {
* @param filename * @param filename
* The filename to open * The filename to open
*/ */
@SuppressWarnings("deprecation")
public final void loadDefaults(File file) { public final void loadDefaults(File file) {
if (!file.exists()) InputStream stream = AuthMe.getInstance().getResource(file.getName());
if (stream == null)
return; 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.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -102,7 +103,7 @@ public final class Settings extends YamlConfiguration {
if (exists()) { if (exists()) {
load(); load();
} else { } else {
loadDefaults(file); loadDefaults(file.getName());
load(); load();
} }
configFile = (YamlConfiguration) plugin.getConfig(); configFile = (YamlConfiguration) plugin.getConfig();
@ -569,6 +570,8 @@ public final class Settings extends YamlConfiguration {
} }
if (contains("Performances.useMultiThreading")) if (contains("Performances.useMultiThreading"))
set("Performances.useMultiThreading", null); set("Performances.useMultiThreading", null);
if (contains("Performances"))
set("Performances", null);
if (!contains("Email.emailWhitelisted")) { if (!contains("Email.emailWhitelisted")) {
set("Email.emailWhitelisted", new ArrayList<String>()); set("Email.emailWhitelisted", new ArrayList<String>());
changes = true; changes = true;
@ -683,7 +686,7 @@ public final class Settings extends YamlConfiguration {
public final void reload() { public final void reload() {
load(); load();
loadDefaults(file); loadDefaults(file.getName());
} }
/** /**
@ -715,12 +718,14 @@ public final class Settings extends YamlConfiguration {
* @param filename * @param filename
* The filename to open * The filename to open
*/ */
public final void loadDefaults(File file) { @SuppressWarnings("deprecation")
if (!file.exists()) public final void loadDefaults(String filename) {
return; InputStream stream = plugin.getResource(filename);
if (stream == null)
setDefaults(YamlConfiguration.loadConfiguration(file)); return;
}
setDefaults(YamlConfiguration.loadConfiguration(stream));
}
/** /**
* Saves current configuration (plus defaults) to disk. * Saves current configuration (plus defaults) to disk.

View File

@ -1,7 +1,7 @@
DataSource: DataSource:
# Can be set to : file, sqlite, mysql # Can be set to: sqlite, mysql
backend: sqlite backend: sqlite
# Do we need to cache all query? # Enable database caching
caching: true caching: true
# Database location # Database location
mySQLHost: 127.0.0.1 mySQLHost: 127.0.0.1
@ -385,10 +385,6 @@ Hooks:
useEssentialsMotd: false useEssentialsMotd: false
# Do we need to cache custom Attributes ? # Do we need to cache custom Attributes ?
customAttributes: false 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: Purge:
# On Enable , does AuthMe need to purge automatically old accounts unused ? # On Enable , does AuthMe need to purge automatically old accounts unused ?
useAutoPurge: false useAutoPurge: false