ModernUO/Projects/UOContent/Misc/AccountPrompt.cs
Kamron Batman 912eaab460
fix: Fixes unresponsive console input (#1720)
### Summary
Fixes an issue where the call priority of `Initialize` functions causes a dead lock because the console input handler was not initialized.
2024-04-05 15:07:43 -07:00

43 lines
1.2 KiB
C#

using System;
using Server.Accounting;
using Server.Logging;
namespace Server.Misc;
public static class AccountPrompt
{
private static readonly ILogger logger = LogFactory.GetLogger(typeof(AccountPrompt));
public static void Initialize()
{
if (Accounts.Count == 0)
{
Console.WriteLine("This server has no accounts.");
Console.Write("Do you want to create the owner account now? (y/n): ");
var answer = ConsoleInputHandler.ReadLine();
if (answer.InsensitiveEquals("y"))
{
Console.WriteLine();
Console.Write("Username: ");
var username = ConsoleInputHandler.ReadLine();
Console.Write("Password: ");
var password = ConsoleInputHandler.ReadLine();
var a = new Account(username, password)
{
AccessLevel = AccessLevel.Owner
};
logger.Information("Owner account created: {Username}", username);
ServerAccess.AddProtectedAccount(a, true);
}
else
{
logger.Warning("No owner account created.");
}
}
}
}