From 89025e31b2d4e93ce89c7cad64cd2ef9f85be443 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Wed, 6 Mar 2024 11:35:00 +0100 Subject: [PATCH] feat: default server address --- .../Controllers/WorldsController.cs | 2 +- Minecraft-Realms-Emulator/Helpers/Database.cs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs index 4692f64..0e9302a 100644 --- a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs +++ b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs @@ -102,7 +102,7 @@ namespace Minecraft_Realms_Emulator.Controllers var connection = new Connection { World = world, - Address = "127.0.0.1" + Address = _context.Configuration.FirstOrDefault(x => x.Key == "defaultServerAddress").Value }; _context.Worlds.Update(world); diff --git a/Minecraft-Realms-Emulator/Helpers/Database.cs b/Minecraft-Realms-Emulator/Helpers/Database.cs index 1c76a4a..2461401 100644 --- a/Minecraft-Realms-Emulator/Helpers/Database.cs +++ b/Minecraft-Realms-Emulator/Helpers/Database.cs @@ -22,9 +22,20 @@ namespace Minecraft_Realms_Emulator.Helpers }; db.Configuration.Add(newsLink); - - db.SaveChanges(); } + + if (db.Configuration.FirstOrDefault(s => s.Key == "defaultServerAddress") == null) + { + var defaultServerAddress = new Configuration + { + Key = "defaultServerAddress", + Value = "127.0.0.1" + }; + + db.Configuration.Add(defaultServerAddress); + } + + db.SaveChanges(); } } }