Fix reloading.

This commit is contained in:
md_5 2013-02-10 21:08:41 +11:00
parent c5e15697a4
commit da9c41ae66
3 changed files with 8 additions and 12 deletions

View File

@ -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.
*

View File

@ -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 );

View File

@ -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> T get(String path, T def)
{
if ( !loaded )
{
load();
}
return get( path, def, config );
}
@SuppressWarnings("unchecked")
private <T> T get(String path, T def, Map submap)
{
if ( !loaded )
{
load();
}
int index = path.indexOf( '.' );
if ( index == -1 )
{