summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-08-28 03:12:16 +0100
committerKHobbits <rob@khobbits.co.uk>2012-08-28 03:12:16 +0100
commitf55316281c6018651ecd71515f462bf6ded57440 (patch)
tree250336108e974a14c13b0131ff09fa46fbd44620
parent413a7beaa48030697782105054808e8e88f4ba4d (diff)
parentd588c3f271419bb6b423d68f95c12eb74c72dc49 (diff)
downloadEssentials-f55316281c6018651ecd71515f462bf6ded57440.tar
Essentials-f55316281c6018651ecd71515f462bf6ded57440.tar.gz
Essentials-f55316281c6018651ecd71515f462bf6ded57440.tar.lz
Essentials-f55316281c6018651ecd71515f462bf6ded57440.tar.xz
Essentials-f55316281c6018651ecd71515f462bf6ded57440.zip
Merge branch 'groupmanager' of github.com:essentials/Essentials into 2.9
-rw-r--r--EssentialsGroupManager/src/Changelog.txt4
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java94
-rw-r--r--EssentialsGroupManager/src/plugin.yml2
3 files changed, 70 insertions, 30 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 63fa8b9d7..2f535277b 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -192,4 +192,6 @@ v 2.0:
- Change to our own Yaml parsing for globalgroups instead of using the YAMLConfiguration class in bukkit.
- Fix a cases sensitivity bug in world loading.
- Stop using the YamlConfiguration in bukkit for our config handling. We can now support periods in world names.
- - Fix GlobalGroups not loading permission nodes. \ No newline at end of file
+ - Fix GlobalGroups not loading permission nodes.
+ - Fix an error with Logging set to 'OFF' triggering a cast exception.
+ - No more null errors from corrupt config.yml's. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
index 34b50825a..95fd35eb0 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
@@ -7,6 +7,7 @@ package org.anjocaido.groupmanager;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
@@ -21,11 +22,11 @@ import org.yaml.snakeyaml.reader.UnicodeReader;
*/
public class GMConfiguration {
- private boolean opOverride;
- private boolean toggleValidate;
- private Integer saveInterval;
- private Integer backupDuration;
- private String loggerLevel;
+ private boolean opOverride = true;
+ private boolean toggleValidate = true;
+ private Integer saveInterval = 10;
+ private Integer backupDuration = 24;
+ private String loggerLevel = "OFF";
private Map<String, Object> mirrorsMap;
@@ -35,6 +36,16 @@ public class GMConfiguration {
public GMConfiguration(GroupManager plugin) {
this.plugin = plugin;
+
+ /*
+ * Set defaults
+ */
+ opOverride = true;
+ toggleValidate = true;
+ saveInterval = 10;
+ backupDuration = 24;
+ loggerLevel = "OFF";
+
load();
}
@@ -44,14 +55,14 @@ public class GMConfiguration {
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
-
+
File configFile = new File(plugin.getDataFolder(), "config.yml");
if (!configFile.exists()) {
try {
Tasks.copy(plugin.getResourceAsStream("config.yml"), configFile);
} catch (IOException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
+ GroupManager.logger.log(Level.SEVERE, "Error creating a new config.yml", ex);
}
}
@@ -61,7 +72,7 @@ public class GMConfiguration {
FileInputStream configInputStream = new FileInputStream(configFile);
GMconfig = (Map<String, Object>) configYAML.load(new UnicodeReader(configInputStream));
configInputStream.close();
-
+
} catch (Exception ex) {
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + configFile.getPath(), ex);
}
@@ -69,26 +80,53 @@ public class GMConfiguration {
/*
* Read our config settings ands store them for reading later.
*/
- Map<String, Object> config = getElement("config", getElement("settings", GMconfig));
-
- opOverride = (Boolean) config.get("opOverrides");
- toggleValidate = (Boolean) config.get("validate_toggle");
-
- /*
- * data node for save/backup timers.
- */
- Map<String, Object> save = getElement("save", getElement("data", getElement("settings", GMconfig)));
-
- saveInterval = (Integer) save.get("minutes");
- backupDuration = (Integer) save.get("hours");
-
- loggerLevel = ((Map<String, String>) getElement("settings", GMconfig).get("logging")).get("level");
-
- /*
- * Store our mirrors map for parsing later.
- */
- mirrorsMap = (Map<String, Object>) ((Map<String, Object>) GMconfig.get("settings")).get("mirrors");
-
+ try {
+ Map<String, Object> config = getElement("config", getElement("settings", GMconfig));
+
+ opOverride = (Boolean) config.get("opOverrides");
+ toggleValidate = (Boolean) config.get("validate_toggle");
+
+ /*
+ * data node for save/backup timers.
+ */
+ try {
+ Map<String, Object> save = getElement("save", getElement("data", getElement("settings", GMconfig)));
+
+ try {
+ saveInterval = (Integer) save.get("minutes");
+ } catch (Exception ex) {
+ GroupManager.logger.log(Level.SEVERE, "Missing or corrupt 'minutes' node. Using default setting", ex);
+ }
+
+ try {
+ backupDuration = (Integer) save.get("hours");
+ } catch (Exception ex) {
+ GroupManager.logger.log(Level.SEVERE, "Missing or corrupt 'hours' node. Using default setting", ex);
+ }
+
+ } catch (Exception ex) {
+ GroupManager.logger.log(Level.SEVERE, "Missing or corrupt 'data' node. Using default settings", ex);
+ }
+
+
+
+ Object level = ((Map<String, String>) getElement("settings", GMconfig).get("logging")).get("level");
+ if (level instanceof String)
+ level = (String) level;
+
+ /*
+ * Store our mirrors map for parsing later.
+ */
+ mirrorsMap = (Map<String, Object>) ((Map<String, Object>) GMconfig.get("settings")).get("mirrors");
+
+ } catch (Exception ex) {
+ /*
+ * Flag the error and use defaults
+ */
+ GroupManager.logger.log(Level.SEVERE, "There are errors in your config.yml. Using default settings", ex);
+
+ mirrorsMap = new HashMap<String, Object>();
+ }
// Setup defaults
adjustLoggerLevel();
plugin.setValidateOnlinePlayer(isToggleValidate());
diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml
index f7faa5896..338991393 100644
--- a/EssentialsGroupManager/src/plugin.yml
+++ b/EssentialsGroupManager/src/plugin.yml
@@ -149,7 +149,7 @@ commands:
usage: /<command>
permissions: groupmanager.mantogglevalidate
mantogglesave:
- description: Toggle on/ff the autosave.
+ description: Toggle on/off the autosave.
usage: /<command>
permissions: groupmanager.mantogglesave
manworld: