From da9c41ae6658625c6aeee03e46d7bda7b19f23b7 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 10 Feb 2013 21:08:41 +1100 Subject: [PATCH] Fix reloading. --- .../bungee/api/config/ConfigurationAdapter.java | 6 ++++++ .../java/net/md_5/bungee/config/Configuration.java | 1 + .../java/net/md_5/bungee/config/YamlConfig.java | 13 +------------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java b/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java index 54f35220..d2d43b79 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java @@ -10,6 +10,12 @@ import java.util.Map; public interface ConfigurationAdapter { + /** + * Reload all the possible values, and if necessary cache them for + * individual getting. + */ + public void load(); + /** * Gets an integer from the specified path. * diff --git a/proxy/src/main/java/net/md_5/bungee/config/Configuration.java b/proxy/src/main/java/net/md_5/bungee/config/Configuration.java index 2304326e..72df6f62 100644 --- a/proxy/src/main/java/net/md_5/bungee/config/Configuration.java +++ b/proxy/src/main/java/net/md_5/bungee/config/Configuration.java @@ -48,6 +48,7 @@ public class Configuration public void load() { ConfigurationAdapter adapter = ProxyServer.getInstance().getConfigurationAdapter(); + adapter.load(); timeout = adapter.getInt( "timeout", timeout ); uuid = adapter.getString( "stats", uuid ); diff --git a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java index 54b52342..313b0011 100644 --- a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java +++ b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java @@ -25,11 +25,11 @@ import org.yaml.snakeyaml.Yaml; public class YamlConfig implements ConfigurationAdapter { - private boolean loaded; private Yaml yaml; private Map config; private final File file = new File( "config.yml" ); + @Override public void load() { try @@ -48,8 +48,6 @@ public class YamlConfig implements ConfigurationAdapter { config = new HashMap(); } - - loaded = true; } catch ( IOException ex ) { throw new RuntimeException( "Could not load configuration!", ex ); @@ -77,21 +75,12 @@ public class YamlConfig implements ConfigurationAdapter private T get(String path, T def) { - if ( !loaded ) - { - load(); - } return get( path, def, config ); } @SuppressWarnings("unchecked") private T get(String path, T def, Map submap) { - if ( !loaded ) - { - load(); - } - int index = path.indexOf( '.' ); if ( index == -1 ) {