summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/EssentialsConf.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/EssentialsConf.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsConf.java158
1 files changed, 79 insertions, 79 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
index d6414fb05..175afb110 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
@@ -221,6 +221,69 @@ public class EssentialsConf extends YamlConfiguration
this.resourceClass = resClass;
}
+ public void save()
+ {
+ try
+ {
+ save(configFile);
+ }
+ catch (IOException ex)
+ {
+ LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
+ }
+ }
+
+ public void saveWithError() throws IOException
+ {
+ save(configFile);
+ }
+
+ @Override
+ public synchronized void save(final File file) throws IOException
+ {
+ if (file == null)
+ {
+ throw new IllegalArgumentException("File cannot be null");
+ }
+
+ Files.createParentDirs(file);
+
+ final String data = saveToString();
+
+ if (data.length() == 0)
+ {
+ return;
+ }
+
+ if (!configFile.exists())
+ {
+ try
+ {
+ LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
+ if (!configFile.createNewFile())
+ {
+ LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
+ }
+ }
+ catch (IOException ex)
+ {
+ LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
+ }
+ }
+
+
+ final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
+
+ try
+ {
+ writer.write(data);
+ }
+ finally
+ {
+ writer.close();
+ }
+ }
+
public boolean hasProperty(final String path)
{
return isSet(path);
@@ -305,89 +368,14 @@ public class EssentialsConf extends YamlConfiguration
set(path, map);
}
- public long getLong(final String path, final long def)
- {
- try
- {
- final Number num = (Number)get(path);
- return num == null ? def : num.longValue();
- }
- catch (ClassCastException ex)
- {
- return def;
- }
- }
-
- @Override
- public double getDouble(final String path, final double def)
+ public void setProperty(String path, List object)
{
- try
- {
- Number num = (Number)get(path);
- return num == null ? def : num.doubleValue();
- }
- catch (ClassCastException ex)
- {
- return def;
- }
+ set(path, new ArrayList(object));
}
- public void save()
+ public void setProperty(String path, Map object)
{
- try
- {
- save(configFile);
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
- }
- }
-
- @Override
- public synchronized void save(final File file) throws IOException
- {
- if (file == null)
- {
- throw new IllegalArgumentException("File cannot be null");
- }
-
- Files.createParentDirs(file);
-
- final String data = saveToString();
-
- if (data.length() == 0)
- {
- return;
- }
-
- if (!configFile.exists())
- {
- try
- {
- LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
- if (!configFile.createNewFile())
- {
- LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
- }
- }
- catch (IOException ex)
- {
- LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
- }
- }
-
-
- final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
-
- try
- {
- writer.write(data);
- }
- finally
- {
- writer.close();
- }
+ set(path, new LinkedHashMap(object));
}
public Object getProperty(String path)
@@ -460,6 +448,12 @@ public class EssentialsConf extends YamlConfiguration
}
@Override
+ public synchronized double getDouble(final String path, final double def)
+ {
+ return super.getDouble(path, def);
+ }
+
+ @Override
public synchronized List<Double> getDoubleList(String path)
{
return super.getDoubleList(path);
@@ -520,6 +514,12 @@ public class EssentialsConf extends YamlConfiguration
}
@Override
+ public synchronized long getLong(final String path, final long def)
+ {
+ return super.getLong(path, def);
+ }
+
+ @Override
public synchronized List<Long> getLongList(String path)
{
return super.getLongList(path);