diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-10-10 23:04:01 +0100 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-10-10 23:04:01 +0100 |
commit | 5d8833a11c43881ab09bc2988409224c1de50751 (patch) | |
tree | c8273d64b5e9c7b687db4eb33b29e1a4b3b6f75e /src | |
parent | 4485364e17c6b573a38189442a62017d7d79d722 (diff) | |
download | bukkit-5d8833a11c43881ab09bc2988409224c1de50751.tar bukkit-5d8833a11c43881ab09bc2988409224c1de50751.tar.gz bukkit-5d8833a11c43881ab09bc2988409224c1de50751.tar.lz bukkit-5d8833a11c43881ab09bc2988409224c1de50751.tar.xz bukkit-5d8833a11c43881ab09bc2988409224c1de50751.zip |
Lazy-load the old and new configs for plugins .getConfig
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/plugin/java/JavaPlugin.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index 6eee36eb..f9966ac5 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -111,10 +111,24 @@ public abstract class JavaPlugin implements Plugin { */ @Deprecated public Configuration getConfiguration() { + if (config == null) { + config = new Configuration(configFile); + config.load(); + } return config; } public FileConfiguration getConfig() { + if (newConfig == null) { + newConfig = YamlConfiguration.loadConfiguration(configFile); + + InputStream defConfigStream = getResource("config.yml"); + if (defConfigStream != null) { + YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); + + newConfig.setDefaults(defConfig); + } + } return newConfig; } @@ -184,16 +198,6 @@ public abstract class JavaPlugin implements Plugin { this.dataFolder = dataFolder; this.classLoader = classLoader; this.configFile = new File(dataFolder, "config.yml"); - this.config = new Configuration(configFile); - this.config.load(); - this.newConfig = YamlConfiguration.loadConfiguration(configFile); - - InputStream defConfigStream = getResource("config.yml"); - if (defConfigStream != null) { - YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); - - newConfig.setDefaults(defConfig); - } if (description.isDatabaseEnabled()) { ServerConfig db = new ServerConfig(); |