From ca57e03ee3497b5a4539b3613e030cc2ffdff46a Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Tue, 20 Feb 2024 09:45:21 +0100 Subject: [PATCH] feat: assign address to world on creation --- .../Controllers/WorldsController.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs index 8b30cdb..4252798 100644 --- a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs +++ b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs @@ -20,9 +20,9 @@ namespace Minecraft_Realms_Emulator.Controllers public async Task> GetWorlds() { 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]; @@ -92,12 +92,20 @@ namespace Minecraft_Realms_Emulator.Controllers var subscription = new Subscription { World = world, - StartDate = ((DateTimeOffset) DateTime.Now).ToUnixTimeMilliseconds().ToString(), + StartDate = ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds().ToString(), SubscriptionType = SubscriptionType.NORMAL.ToString() }; + var connection = new Connection + { + World = world, + Address = "127.0.0.1" + }; + _context.Worlds.Update(world); + _context.Subscriptions.Add(subscription); + _context.Connections.Add(connection); _context.SaveChanges(); @@ -131,7 +139,7 @@ namespace Minecraft_Realms_Emulator.Controllers public async Task> Close(int id) { var worlds = await _context.Worlds.ToListAsync(); - + var world = worlds.Find(w => w.Id == id); if (world == null) return NotFound("World not found");