geforkt von Mirrors/Paper
Lazy-load the old and new configs for plugins .getConfig
By: Nathan Adams <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
429eb80d6e
Commit
1ad373d9f6
@ -111,10 +111,24 @@ public abstract class JavaPlugin implements Plugin {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Configuration getConfiguration() {
|
public Configuration getConfiguration() {
|
||||||
|
if (config == null) {
|
||||||
|
config = new Configuration(configFile);
|
||||||
|
config.load();
|
||||||
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileConfiguration getConfig() {
|
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;
|
return newConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,16 +198,6 @@ public abstract class JavaPlugin implements Plugin {
|
|||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
this.classLoader = classLoader;
|
this.classLoader = classLoader;
|
||||||
this.configFile = new File(dataFolder, "config.yml");
|
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()) {
|
if (description.isDatabaseEnabled()) {
|
||||||
ServerConfig db = new ServerConfig();
|
ServerConfig db = new ServerConfig();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren