mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-12-22 04:18:21 -05:00
feat: opening and closing world
This commit is contained in:
parent
e02db741d6
commit
4e737305dd
@ -81,7 +81,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
||||
{
|
||||
var worlds = await _context.Worlds.ToListAsync();
|
||||
|
||||
var world = worlds.Find(p => p.Id == id);
|
||||
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");
|
||||
@ -97,10 +97,42 @@ namespace Minecraft_Realms_Emulator.Controllers
|
||||
}
|
||||
|
||||
[HttpPost("{id}/reset")]
|
||||
public ActionResult<World> Reset(int id)
|
||||
public ActionResult<bool> Reset(int id)
|
||||
{
|
||||
Console.WriteLine($"Resetting world {id}");
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
[HttpPut("{id}/open")]
|
||||
public async Task<ActionResult<bool>> Open(int id)
|
||||
{
|
||||
var worlds = await _context.Worlds.ToListAsync();
|
||||
|
||||
var world = worlds.Find(w => w.Id == id);
|
||||
|
||||
if (world == null) return NotFound("World not found");
|
||||
|
||||
world.State = State.OPEN.ToString();
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
[HttpPut("{id}/close")]
|
||||
public async Task<ActionResult<bool>> 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");
|
||||
|
||||
world.State = State.CLOSED.ToString();
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user