13
0
geforkt von Mirrors/Paper

Added reloadConfig() plugin method

By: Nathan Adams <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2011-10-11 15:50:59 +01:00
Ursprung 71d1bb3e2d
Commit b94e100930
2 geänderte Dateien mit 17 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -58,6 +58,11 @@ public interface Plugin extends CommandExecutor {
* Saves the {@link FileConfiguration} retrievable by {@link #getConfig()}.
*/
public void saveConfig();
/**
* Discards any data in {@link #getConfig()} and reloads from disk.
*/
public void reloadConfig();
/**
* Gets the associated PluginLoader responsible for this plugin

Datei anzeigen

@ -120,18 +120,22 @@ public abstract class JavaPlugin implements Plugin {
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);
}
reloadConfig();
}
return newConfig;
}
public void reloadConfig() {
newConfig = YamlConfiguration.loadConfiguration(configFile);
InputStream defConfigStream = getResource("config.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
newConfig.setDefaults(defConfig);
}
}
public void saveConfig() {
try {
newConfig.save(configFile);