⚙️Advanced Configurations
In case you need more flexibility or customization, the configuration system has you covered!
Getting a configuration
public class MyFirstPlugin : Plugin
{
// LevelingConfig is a serializable class.
public LevelingConfig LevelsConfig;
public override void LoadConfigs()
{
base.LoadConfigs();
// This will read the LevelingConfig configuration from the lvls.yml file
// In case the file doesn't exist, it will be created with its default values
LevelsConfig = this.LoadConfig<LevelingConfig>("lvls.yml");
}
}private bool _hasIncorrectSettings = false;
public override void LoadConfigs()
{
base.LoadConfigs();
// We could, for example, avoid to enable the plugin at all.
_hasIncorrectSettings = !this.TryLoadConfig("lvls.yml", out LevelsConfig);
}
public override void Enable()
{
// Enable is called after the settings are loaded.
// We can directly check if the user has incorrect settings.
if (_hasIncorrectSettings)
{
Logger.Error("Detected incorrect settings, not loading");
return;
}Saving a configuration
Last updated