diff --git a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs index ab9671f..3e61f08 100644 --- a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs +++ b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs @@ -21,6 +21,43 @@ namespace Minecraft_Realms_Emulator.Controllers { 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() { Servers = worlds diff --git a/Minecraft-Realms-Emulator/appsettings.json b/Minecraft-Realms-Emulator/appsettings.json index bac46d0..282fb22 100644 --- a/Minecraft-Realms-Emulator/appsettings.json +++ b/Minecraft-Realms-Emulator/appsettings.json @@ -1,6 +1,6 @@ { "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": { "LogLevel": {