Hello, I think this could help you
private class Command
{
public string name;
public string type;
public string response;
}
private class PluginConfig
{
public List<Command> commands = new List<Command>();
}
private PluginConfig _config;
protected override void SaveConfig() => Config.WriteObject(_config, true);
protected override void LoadDefaultConfig()
{
_config = new PluginConfig();
// Your examples
_config.commands.Add(new Command()
{
name = "help" ,
type = "text",
response = "Rule 1. No cheating."
});
_config.commands.Add(new Command()
{
name = "ping",
type = "ping",
response = "generatedResponse"
});
SaveConfig();
}
protected override void LoadConfig()
{
base.LoadConfig();
try
{
_config = Config.ReadObject<PluginConfig>();
if (_config == null)
throw new Exception();
SaveConfig(); // override posible obsolet / outdated config
}
catch (Exception)
{
PrintError("Loaded default config.");
LoadDefaultConfig();
}
}
Output:
{
"commands": [
{
"name": "help",
"type": "text",
"response": "Rule 1. No cheating."
},
{
"name": "ping",
"type": "ping",
"response": "generatedResponse"
}
]
}