Adds a custom plugin implementation that uses the StargateYamlConfiguration
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:
@@ -0,0 +1,38 @@
|
||||
package net.knarcraft.knarlib.plugin;
|
||||
|
||||
import net.knarcraft.knarlib.config.StargateYamlConfiguration;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A plugin that uses a Stargate YAML configuration in order to retain all configuration comments
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class ConfigCommentPlugin implements Plugin {
|
||||
|
||||
protected StargateYamlConfiguration configuration = null;
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
this.configuration = StargateYamlConfiguration.loadConfiguration(this, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
if (this.configuration == null) {
|
||||
this.reloadConfig();
|
||||
}
|
||||
StargateYamlConfiguration.saveConfiguration(this, this.configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public FileConfiguration getConfig() {
|
||||
if (this.configuration == null) {
|
||||
this.reloadConfig();
|
||||
}
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user