implement plugins section

This commit is contained in:
zznty
2022-10-04 19:31:59 +07:00
parent 7136a93c76
commit 1e29719125
9 changed files with 165 additions and 3 deletions

View File

@@ -58,7 +58,9 @@ public class ApiServerManager : Manager
.WithController<ServerController>()
.WithController<SettingsController>()
.WithController<WorldsController>()
.WithController<ChatController>())
.WithController<ChatController>()
.WithController<PluginsController>()
.WithController<PluginDownloadsController>())
.WithModule(new LogsModule("/api/live/logs", true))
.WithModule(chatModule)
.WithBearerToken("/api", new SymmetricSecurityKey(Convert.FromBase64String(_config.SecurityKey)), new BasicAuthorizationServerProvider());

View File

@@ -70,8 +70,11 @@ public class SettingManager : Manager
var persistentType = persistentInstance.GetType();
var getter = persistentType.GetProperty("Data")!;
var settingType = persistentType.GenericTypeArguments[0];
RegisterSetting(plugin.Name, getter.GetValue(persistentInstance), persistentType.GenericTypeArguments[0]);
RegisterSetting(plugin.Name, getter.GetValue(persistentInstance), settingType);
PluginSettings.Add(plugin.Id, settingType.FullName!);
}
}
@@ -92,6 +95,7 @@ public class SettingManager : Manager
}
public IDictionary<string, Setting> Settings { get; } = new ConcurrentDictionary<string, Setting>();
public IDictionary<Guid, string> PluginSettings { get; } = new ConcurrentDictionary<Guid, string>();
}
public record Setting(string Name, Type Type, JsonSchema Schema, object Value);