mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-11-21 21:58:21 -05:00
chore: tidy up code
This commit is contained in:
parent
b390a9105f
commit
c5594b3460
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.8.34511.84
|
VisualStudioVersion = 17.8.34511.84
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -3,6 +3,8 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Minecraft_Realms_Emulator.Attributes;
|
using Minecraft_Realms_Emulator.Attributes;
|
||||||
using Minecraft_Realms_Emulator.Data;
|
using Minecraft_Realms_Emulator.Data;
|
||||||
using Minecraft_Realms_Emulator.Entities;
|
using Minecraft_Realms_Emulator.Entities;
|
||||||
|
using Minecraft_Realms_Emulator.Requests;
|
||||||
|
using Minecraft_Realms_Emulator.Responses;
|
||||||
|
|
||||||
namespace Minecraft_Realms_Emulator.Controllers
|
namespace Minecraft_Realms_Emulator.Controllers
|
||||||
{
|
{
|
||||||
@ -19,7 +21,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<ServersArray>> GetWorlds()
|
public async Task<ActionResult<ServersResponse>> GetWorlds()
|
||||||
{
|
{
|
||||||
string cookie = Request.Headers.Cookie;
|
string cookie = Request.Headers.Cookie;
|
||||||
|
|
||||||
@ -39,8 +41,8 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
OwnerUUID = playerUUID,
|
OwnerUUID = playerUUID,
|
||||||
Name = null,
|
Name = null,
|
||||||
Motd = null,
|
Motd = null,
|
||||||
State = State.UNINITIALIZED.ToString(),
|
State = "UNINITIALIZED",
|
||||||
WorldType = WorldType.NORMAL.ToString(),
|
WorldType = "NORMAL",
|
||||||
MaxPlayers = 10,
|
MaxPlayers = 10,
|
||||||
MinigameId = null,
|
MinigameId = null,
|
||||||
MinigameName = null,
|
MinigameName = null,
|
||||||
@ -111,7 +113,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
allWorlds.Add(response);
|
allWorlds.Add(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServersArray servers = new()
|
ServersResponse servers = new()
|
||||||
{
|
{
|
||||||
Servers = allWorlds
|
Servers = allWorlds
|
||||||
};
|
};
|
||||||
@ -151,14 +153,14 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id}/initialize")]
|
[HttpPost("{id}/initialize")]
|
||||||
public async Task<ActionResult<World>> Initialize(int id, WorldCreate body)
|
public async Task<ActionResult<World>> Initialize(int id, WorldCreateRequest body)
|
||||||
{
|
{
|
||||||
var worlds = await _context.Worlds.ToListAsync();
|
var worlds = await _context.Worlds.ToListAsync();
|
||||||
|
|
||||||
var world = worlds.Find(w => w.Id == id);
|
var world = worlds.Find(w => w.Id == id);
|
||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
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
|
var subscription = new Subscription
|
||||||
{
|
{
|
||||||
@ -168,7 +170,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
|
|
||||||
world.Name = body.Name;
|
world.Name = body.Name;
|
||||||
world.Motd = body.Description;
|
world.Motd = body.Description;
|
||||||
world.State = State.OPEN.ToString();
|
world.State = "OPEN";
|
||||||
world.Subscription = subscription;
|
world.Subscription = subscription;
|
||||||
|
|
||||||
var connection = new Connection
|
var connection = new Connection
|
||||||
@ -203,7 +205,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
|
|
||||||
world.State = State.OPEN.ToString();
|
world.State = "OPEN";
|
||||||
|
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
@ -219,7 +221,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
|
|
||||||
world.State = State.CLOSED.ToString();
|
world.State = "CLOSED";
|
||||||
|
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
@ -227,7 +229,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id}")]
|
[HttpPost("{id}")]
|
||||||
public async Task<ActionResult<bool>> UpdateWorld(int id, WorldCreate body)
|
public async Task<ActionResult<bool>> UpdateWorld(int id, WorldCreateRequest body)
|
||||||
{
|
{
|
||||||
var worlds = await _context.Worlds.ToListAsync();
|
var worlds = await _context.Worlds.ToListAsync();
|
||||||
|
|
||||||
@ -251,11 +253,11 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{Id}/backups")]
|
[HttpGet("{Id}/backups")]
|
||||||
public async Task<ActionResult<BackupList>> GetBackups(int id)
|
public async Task<ActionResult<BackupsResponse>> GetBackups(int id)
|
||||||
{
|
{
|
||||||
var backups = await _context.Backups.Where(b => b.World.Id == id).ToListAsync();
|
var backups = await _context.Backups.Where(b => b.World.Id == id).ToListAsync();
|
||||||
|
|
||||||
BackupList worldBackups = new()
|
BackupsResponse worldBackups = new()
|
||||||
{
|
{
|
||||||
Backups = backups
|
Backups = backups
|
||||||
};
|
};
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
namespace Minecraft_Realms_Emulator.Entities
|
|
||||||
{
|
|
||||||
public class BackupList
|
|
||||||
{
|
|
||||||
public List<Backup> Backups { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace Minecraft_Realms_Emulator.Entities
|
|
||||||
{
|
|
||||||
public class ServersArray
|
|
||||||
{
|
|
||||||
public List<WorldResponse>? Servers { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace Minecraft_Realms_Emulator.Entities
|
|
||||||
{
|
|
||||||
public enum State
|
|
||||||
{
|
|
||||||
OPEN,
|
|
||||||
CLOSED,
|
|
||||||
ADMIN_LOCK,
|
|
||||||
UNINITIALIZED
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace Minecraft_Realms_Emulator.Entities
|
|
||||||
{
|
|
||||||
public enum WorldType
|
|
||||||
{
|
|
||||||
NORMAL,
|
|
||||||
SUPERFLAT,
|
|
||||||
LARGEBIOMES,
|
|
||||||
AMPLIFIED
|
|
||||||
}
|
|
||||||
}
|
|
@ -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? Name { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
9
Minecraft-Realms-Emulator/Responses/BackupsResponse.cs
Normal file
9
Minecraft-Realms-Emulator/Responses/BackupsResponse.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using Minecraft_Realms_Emulator.Entities;
|
||||||
|
|
||||||
|
namespace Minecraft_Realms_Emulator.Responses
|
||||||
|
{
|
||||||
|
public class BackupsResponse
|
||||||
|
{
|
||||||
|
public List<Backup> Backups { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
Minecraft-Realms-Emulator/Responses/ServersResponse.cs
Normal file
9
Minecraft-Realms-Emulator/Responses/ServersResponse.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using Minecraft_Realms_Emulator.Entities;
|
||||||
|
|
||||||
|
namespace Minecraft_Realms_Emulator.Responses
|
||||||
|
{
|
||||||
|
public class ServersResponse
|
||||||
|
{
|
||||||
|
public List<WorldResponse>? Servers { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user