mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-14 19:42:20 +01:00
Added reloadConfig() plugin method
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
71d1bb3e2d
commit
b94e100930
@ -58,6 +58,11 @@ public interface Plugin extends CommandExecutor {
|
|||||||
* Saves the {@link FileConfiguration} retrievable by {@link #getConfig()}.
|
* Saves the {@link FileConfiguration} retrievable by {@link #getConfig()}.
|
||||||
*/
|
*/
|
||||||
public void saveConfig();
|
public void saveConfig();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discards any data in {@link #getConfig()} and reloads from disk.
|
||||||
|
*/
|
||||||
|
public void reloadConfig();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the associated PluginLoader responsible for this plugin
|
* Gets the associated PluginLoader responsible for this plugin
|
||||||
|
@ -120,18 +120,22 @@ public abstract class JavaPlugin implements Plugin {
|
|||||||
|
|
||||||
public FileConfiguration getConfig() {
|
public FileConfiguration getConfig() {
|
||||||
if (newConfig == null) {
|
if (newConfig == null) {
|
||||||
newConfig = YamlConfiguration.loadConfiguration(configFile);
|
reloadConfig();
|
||||||
|
|
||||||
InputStream defConfigStream = getResource("config.yml");
|
|
||||||
if (defConfigStream != null) {
|
|
||||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
|
||||||
|
|
||||||
newConfig.setDefaults(defConfig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return newConfig;
|
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() {
|
public void saveConfig() {
|
||||||
try {
|
try {
|
||||||
newConfig.save(configFile);
|
newConfig.save(configFile);
|
||||||
|
Loading…
Reference in New Issue
Block a user