feat: create uninitialized world if a player doesn't have one

This commit is contained in:
CyberL1 2024-02-03 10:15:28 +01:00
parent 9183c566a6
commit 94608fd792
2 changed files with 38 additions and 1 deletions

View File

@ -21,6 +21,43 @@ namespace Minecraft_Realms_Emulator.Controllers
{ {
var worlds = await _context.Worlds.ToListAsync(); var worlds = await _context.Worlds.ToListAsync();
string cookie = Request.Headers.Cookie;
string playerUUID = cookie.Split(";")[0].Split(":")[2];
string playerName = cookie.Split(";")[1].Split("=")[1];
var hasWorld = worlds.Find(p => p.OwnerUUID == playerUUID);
if (hasWorld == null)
{
var world = new World
{
RemoteSubscriptionId = Guid.NewGuid().ToString(),
Owner = playerName,
OwnerUUID = playerUUID,
Name = null,
Motd = null,
State = State.UNINITIALIZED.ToString(),
DaysLeft = 30,
Expired = false,
ExpiredTrial = false,
WorldType = WorldType.NORMAL.ToString(),
Players = [],
MaxPlayers = 10,
MinigameId = null,
MinigameName = null,
MinigameImage = null,
Slots = [],
ActiveSlot = 1,
Member = false
};
worlds.Add(world);
_context.Worlds.Add(world);
_context.SaveChanges();
}
ServersArray servers = new() ServersArray servers = new()
{ {
Servers = worlds Servers = worlds

View File

@ -1,6 +1,6 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"DefaultConnection": "User Id=postgres.aquqykciubzfolgrftwa;Password=8ypKY2pSWNRrlhCt;Server=aws-0-us-west-1.pooler.supabase.com;Port=5432;Database=postgres" "DefaultConnection": "User Id=postgres.aquqykciubzfolgrftwa;Password=SNYcLhJsLGiWeB2K;Server=aws-0-us-west-1.pooler.supabase.com;Port=5432;Database=postgres"
}, },
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {