mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-21 23:42:45 +01:00
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Phantom.Common.Data.Agent;
|
|
using Phantom.Server.Minecraft;
|
|
using Phantom.Server.Services;
|
|
using Phantom.Server.Services.Agents;
|
|
using Phantom.Server.Services.Audit;
|
|
using Phantom.Server.Services.Events;
|
|
using Phantom.Server.Services.Instances;
|
|
using Phantom.Server.Services.Rpc;
|
|
using Phantom.Server.Services.Users;
|
|
using Phantom.Utils.Runtime;
|
|
using WebLauncher = Phantom.Server.Web.Launcher;
|
|
|
|
namespace Phantom.Server;
|
|
|
|
sealed class WebConfigurator : WebLauncher.IConfigurator {
|
|
private readonly ServiceConfiguration serviceConfiguration;
|
|
private readonly TaskManager taskManager;
|
|
private readonly AgentAuthToken agentToken;
|
|
|
|
public WebConfigurator(ServiceConfiguration serviceConfiguration, TaskManager taskManager, AgentAuthToken agentToken) {
|
|
this.serviceConfiguration = serviceConfiguration;
|
|
this.taskManager = taskManager;
|
|
this.agentToken = agentToken;
|
|
}
|
|
|
|
public void ConfigureServices(IServiceCollection services) {
|
|
services.AddSingleton(serviceConfiguration);
|
|
services.AddSingleton(taskManager);
|
|
services.AddSingleton(agentToken);
|
|
services.AddSingleton<AgentManager>();
|
|
services.AddSingleton<AgentJavaRuntimesManager>();
|
|
services.AddSingleton<EventLog>();
|
|
services.AddSingleton<InstanceManager>();
|
|
services.AddSingleton<InstanceLogManager>();
|
|
services.AddSingleton<MinecraftVersions>();
|
|
services.AddSingleton<MessageToServerListenerFactory>();
|
|
|
|
services.AddScoped<IdentityLookup>();
|
|
services.AddScoped<AuditLog>();
|
|
}
|
|
|
|
public async Task LoadFromDatabase(IServiceProvider serviceProvider) {
|
|
await serviceProvider.GetRequiredService<AgentManager>().Initialize();
|
|
await serviceProvider.GetRequiredService<InstanceManager>().Initialize();
|
|
}
|
|
}
|