Update Program.cs

This commit is contained in:
sonic 2024-08-18 19:41:47 +02:00 committed by GitHub
parent 1bfbc75d36
commit c852c3834f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,14 +11,12 @@ using System.Net;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
bool ConsoleOptions = builder.Configuration.GetSection("ConsoleOptions").GetValue<bool>("Show logs");
bool GamePromptOptions = builder.Configuration.GetSection("GamePromptOptions").GetValue<bool>("Open Game");
// shows information about loading assets/api stuff bool gameOpenEnable = builder.Configuration.GetSection("GamePromptOptions").GetValue<bool>("Enabled");
if (ConsoleOptions == true) string ClientPath = builder.Configuration.GetSection("GamePromptOptions").GetValue<string>("ClientPath");
{
VerboseLogging.log(); // shows that the server is starting
} ConsoleFunctions.log("Server Start");
builder.Services.Configure<AssetServerConfig>(builder.Configuration.GetSection("AssetServer")); builder.Services.Configure<AssetServerConfig>(builder.Configuration.GetSection("AssetServer"));
builder.Services.Configure<ApiServerConfig>(builder.Configuration.GetSection("ApiServer")); builder.Services.Configure<ApiServerConfig>(builder.Configuration.GetSection("ApiServer"));
@ -74,11 +72,21 @@ app.UseAuthorization();
app.MapControllers(); app.MapControllers();
// Shows message that server started // Shows message that server is running
VerboseLogging.ServerStartedMessage();
if (GamePromptOptions) ConsoleFunctions.log("Server Running");
//asks the user to automally open the game client
if (gameOpenEnable == true)
{ {
OpenGamePrompt.prompt(); if (ClientPath.EndsWith("exe"))
{
ConsoleFunctions.prompt(ClientPath);
}
else
{
Console.WriteLine("Invalid or empty Configuration value, Check your configuration file appsettings.json ClientPath is incorrect");
}
} }
PrintInfo.print();
app.Run(); app.Run();