diff --git a/Minecraft-Realms-Emulator.sln b/Minecraft-Realms-Emulator.sln index a86118c..e229d1e 100644 --- a/Minecraft-Realms-Emulator.sln +++ b/Minecraft-Realms-Emulator.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34511.84 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Minecraft-Realms-Emulator", "Minecraft-Realms-Emulator\Minecraft-Realms-Emulator.csproj", "{A9A21AAF-EF1B-4723-9407-51FD6B831B98}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Minecraft-Realms-Emulator", "Minecraft-Realms-Emulator\Minecraft-Realms-Emulator.csproj", "{A9A21AAF-EF1B-4723-9407-51FD6B831B98}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs index 80de8bd..fadcc2a 100644 --- a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs +++ b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs @@ -3,6 +3,8 @@ using Microsoft.EntityFrameworkCore; using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Entities; +using Minecraft_Realms_Emulator.Requests; +using Minecraft_Realms_Emulator.Responses; namespace Minecraft_Realms_Emulator.Controllers { @@ -19,7 +21,7 @@ namespace Minecraft_Realms_Emulator.Controllers } [HttpGet] - public async Task> GetWorlds() + public async Task> GetWorlds() { string cookie = Request.Headers.Cookie; @@ -39,8 +41,8 @@ namespace Minecraft_Realms_Emulator.Controllers OwnerUUID = playerUUID, Name = null, Motd = null, - State = State.UNINITIALIZED.ToString(), - WorldType = WorldType.NORMAL.ToString(), + State = "UNINITIALIZED", + WorldType = "NORMAL", MaxPlayers = 10, MinigameId = null, MinigameName = null, @@ -111,7 +113,7 @@ namespace Minecraft_Realms_Emulator.Controllers allWorlds.Add(response); } - ServersArray servers = new() + ServersResponse servers = new() { Servers = allWorlds }; @@ -151,14 +153,14 @@ namespace Minecraft_Realms_Emulator.Controllers } [HttpPost("{id}/initialize")] - public async Task> Initialize(int id, WorldCreate body) + public async Task> Initialize(int id, WorldCreateRequest body) { var worlds = await _context.Worlds.ToListAsync(); var world = worlds.Find(w => w.Id == id); if (world == null) return NotFound("World not found"); - if (world.State != State.UNINITIALIZED.ToString()) return NotFound("World already initialized"); + if (world.State != "UNINITIALIZED") return NotFound("World already initialized"); var subscription = new Subscription { @@ -168,7 +170,7 @@ namespace Minecraft_Realms_Emulator.Controllers world.Name = body.Name; world.Motd = body.Description; - world.State = State.OPEN.ToString(); + world.State = "OPEN"; world.Subscription = subscription; var connection = new Connection @@ -203,7 +205,7 @@ namespace Minecraft_Realms_Emulator.Controllers if (world == null) return NotFound("World not found"); - world.State = State.OPEN.ToString(); + world.State = "OPEN"; _context.SaveChanges(); @@ -219,7 +221,7 @@ namespace Minecraft_Realms_Emulator.Controllers if (world == null) return NotFound("World not found"); - world.State = State.CLOSED.ToString(); + world.State = "CLOSED"; _context.SaveChanges(); @@ -227,7 +229,7 @@ namespace Minecraft_Realms_Emulator.Controllers } [HttpPost("{id}")] - public async Task> UpdateWorld(int id, WorldCreate body) + public async Task> UpdateWorld(int id, WorldCreateRequest body) { var worlds = await _context.Worlds.ToListAsync(); @@ -251,11 +253,11 @@ namespace Minecraft_Realms_Emulator.Controllers } [HttpGet("{Id}/backups")] - public async Task> GetBackups(int id) + public async Task> GetBackups(int id) { var backups = await _context.Backups.Where(b => b.World.Id == id).ToListAsync(); - BackupList worldBackups = new() + BackupsResponse worldBackups = new() { Backups = backups }; diff --git a/Minecraft-Realms-Emulator/Entities/BackupList.cs b/Minecraft-Realms-Emulator/Entities/BackupList.cs deleted file mode 100644 index 9ce2935..0000000 --- a/Minecraft-Realms-Emulator/Entities/BackupList.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Minecraft_Realms_Emulator.Entities -{ - public class BackupList - { - public List Backups { get; set; } - } -} diff --git a/Minecraft-Realms-Emulator/Entities/ServersArray.cs b/Minecraft-Realms-Emulator/Entities/ServersArray.cs deleted file mode 100644 index acbf11b..0000000 --- a/Minecraft-Realms-Emulator/Entities/ServersArray.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Minecraft_Realms_Emulator.Entities -{ - public class ServersArray - { - public List? Servers { get; set; } - } -} diff --git a/Minecraft-Realms-Emulator/Entities/State.cs b/Minecraft-Realms-Emulator/Entities/State.cs deleted file mode 100644 index 824e7ea..0000000 --- a/Minecraft-Realms-Emulator/Entities/State.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Minecraft_Realms_Emulator.Entities -{ - public enum State - { - OPEN, - CLOSED, - ADMIN_LOCK, - UNINITIALIZED - } -} diff --git a/Minecraft-Realms-Emulator/Entities/WorldType.cs b/Minecraft-Realms-Emulator/Entities/WorldType.cs deleted file mode 100644 index 02601e2..0000000 --- a/Minecraft-Realms-Emulator/Entities/WorldType.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Minecraft_Realms_Emulator.Entities -{ - public enum WorldType - { - NORMAL, - SUPERFLAT, - LARGEBIOMES, - AMPLIFIED - } -} diff --git a/Minecraft-Realms-Emulator/Entities/WorldCreate.cs b/Minecraft-Realms-Emulator/Requests/WorldCreateRequest.cs similarity index 55% rename from Minecraft-Realms-Emulator/Entities/WorldCreate.cs rename to Minecraft-Realms-Emulator/Requests/WorldCreateRequest.cs index 71efe94..d47a274 100644 --- a/Minecraft-Realms-Emulator/Entities/WorldCreate.cs +++ b/Minecraft-Realms-Emulator/Requests/WorldCreateRequest.cs @@ -1,6 +1,6 @@ -namespace Minecraft_Realms_Emulator.Entities +namespace Minecraft_Realms_Emulator.Requests { - public class WorldCreate + public class WorldCreateRequest { public string? Name { get; set; } public string? Description { get; set; } diff --git a/Minecraft-Realms-Emulator/Responses/BackupsResponse.cs b/Minecraft-Realms-Emulator/Responses/BackupsResponse.cs new file mode 100644 index 0000000..8c0742e --- /dev/null +++ b/Minecraft-Realms-Emulator/Responses/BackupsResponse.cs @@ -0,0 +1,9 @@ +using Minecraft_Realms_Emulator.Entities; + +namespace Minecraft_Realms_Emulator.Responses +{ + public class BackupsResponse + { + public List Backups { get; set; } + } +} diff --git a/Minecraft-Realms-Emulator/Responses/ServersResponse.cs b/Minecraft-Realms-Emulator/Responses/ServersResponse.cs new file mode 100644 index 0000000..01c3e96 --- /dev/null +++ b/Minecraft-Realms-Emulator/Responses/ServersResponse.cs @@ -0,0 +1,9 @@ +using Minecraft_Realms_Emulator.Entities; + +namespace Minecraft_Realms_Emulator.Responses +{ + public class ServersResponse + { + public List? Servers { get; set; } + } +}