-
Notifications
You must be signed in to change notification settings - Fork 1
Plugin Configs
You can use the Synapse.Api.Plugin.Plugin.Config
to get the configs that are in server-configs.yml
This is a YAML config so you can do for example: Config.GetString("configname","default value");
or Config.GetInt("configname",default value)
to get the values.
Example:
In the Plugin
Plugin.Config.GetBool("myplugin_enabled",true)
In the Config file
myplugin_enabled: false (or true)
If you need an own config file, you can just create one in your own directory which Synapse creates for you.
If you add the string OwnPluginFolder
inside your Plugin and create a file, Synapse will automaticly create a folder.
Example:
using Synapse;
namespace Example
{
public class Example : Plugin
{
public override void OnEnable()
{
File.Create(this.OwnPluginFolder + "FileName.txt"); // This will create a FileName.txt in \Synapse\Plugins\Server-{ServerPort}\{Your Plugin Name}
}
public override string GetName => "YourPluginName";
}
}
Your main plugin class which inherit from Synapse.Plugin contains a ConfigReloadEvent
which is activated by Synapse when all configs are to be reloaded. Try to always implement this with your plugin, if you are using configs, so that the Server Administrator can reload the configs.
Example:
using Synapse;
namespace Example
{
public class Example : Plugin
{
string exampleConfig;
public override void OnEnable()
{
ReloadConfigs(); //This will initialise the configs the first time the Server starts.
this.ConfigReloadEvent += ReloadConfigs; //This will refresh the configs if the Server Admin wants to reload the configs
}
public override string GetName => "YourPluginName";
public void ReloadConfigs()
{
exampleConfig = Plugin.GetString("example","Hello World");
}
}
}
Have you understand everything? The next step would be to learn how the the Translation System of Synapse works!