Makes sure configuration pointers are still valid after reloading
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
This commit is contained in:
@@ -40,14 +40,6 @@ public class StargateYamlConfiguration extends YamlConfiguration {
|
||||
private static final String END_OF_COMMENT = "_endOfComment_";
|
||||
private static final String START_OF_COMMENT = "comment_";
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
protected String buildHeader() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String saveToString() {
|
||||
@@ -61,6 +53,19 @@ public class StargateYamlConfiguration extends YamlConfiguration {
|
||||
super.loadFromString(this.convertCommentsToYAMLMappings(contents));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads this configuration
|
||||
*
|
||||
* @param plugin <p>The plugin this configuration belongs to</p>
|
||||
*/
|
||||
public void reload(@NotNull Plugin plugin) {
|
||||
try {
|
||||
this.load(new File(plugin.getDataFolder(), ConfigHelper.getConfigFile()));
|
||||
} catch (IOException | InvalidConfigurationException exception) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Unable to load the configuration! Message: " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the configuration of the given plugin
|
||||
*
|
||||
|
@@ -46,7 +46,11 @@ public abstract class ConfigCommentPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
this.configuration = StargateYamlConfiguration.loadConfiguration(this, true);
|
||||
if (this.configuration == null) {
|
||||
this.configuration = StargateYamlConfiguration.loadConfiguration(this, true);
|
||||
} else {
|
||||
this.configuration.reload(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user