fix: check if world is initialized

This commit is contained in:
CyberL1 2024-10-20 14:26:30 +02:00
parent 83c43ce73d
commit c2f62fdffb
2 changed files with 22 additions and 0 deletions

View File

@ -409,6 +409,17 @@ namespace Minecraft_Realms_Emulator.Modes.External
var world = await _context.Worlds.Include(w => w.Players).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld.Subscription).FirstOrDefaultAsync(w => w.Id == wId);
if (world.State == nameof(StateEnum.UNINITIALIZED))
{
ErrorResponse error = new()
{
ErrorCode = 400,
ErrorMsg = "Initialize the world first"
};
return StatusCode(400, error);
}
Slot activeSlot = world.Slots.Find(s => s.SlotId == world.ActiveSlot);
List<SlotResponse> slots = [];

View File

@ -412,6 +412,17 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
var world = await _context.Worlds.Include(w => w.Players).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld.Subscription).FirstOrDefaultAsync(w => w.Id == wId);
if (world.State == nameof(StateEnum.UNINITIALIZED))
{
ErrorResponse error = new()
{
ErrorCode = 400,
ErrorMsg = "Initialize the world first"
};
return StatusCode(400, error);
}
Slot activeSlot = world.Slots.Find(s => s.SlotId == world.ActiveSlot);
List<SlotResponse> slots = [];