mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-08 16:12:18 -07:00
Added reloadConfig() plugin method
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
@@ -59,6 +59,11 @@ public interface Plugin extends CommandExecutor {
|
|||||||
*/
|
*/
|
||||||
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,6 +120,12 @@ public abstract class JavaPlugin implements Plugin {
|
|||||||
|
|
||||||
public FileConfiguration getConfig() {
|
public FileConfiguration getConfig() {
|
||||||
if (newConfig == null) {
|
if (newConfig == null) {
|
||||||
|
reloadConfig();
|
||||||
|
}
|
||||||
|
return newConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadConfig() {
|
||||||
newConfig = YamlConfiguration.loadConfiguration(configFile);
|
newConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
|
||||||
InputStream defConfigStream = getResource("config.yml");
|
InputStream defConfigStream = getResource("config.yml");
|
||||||
@@ -129,8 +135,6 @@ public abstract class JavaPlugin implements Plugin {
|
|||||||
newConfig.setDefaults(defConfig);
|
newConfig.setDefaults(defConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveConfig() {
|
public void saveConfig() {
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user