mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-11-22 06:08:22 -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 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 == null) return NotFound("World not found");
|
||||||
if (world.State != State.UNINITIALIZED.ToString()) return NotFound("World already initialized");
|
if (world.State != State.UNINITIALIZED.ToString()) return NotFound("World already initialized");
|
||||||
@ -97,10 +97,42 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id}/reset")]
|
[HttpPost("{id}/reset")]
|
||||||
public ActionResult<World> Reset(int id)
|
public ActionResult<bool> Reset(int id)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Resetting world {id}");
|
Console.WriteLine($"Resetting world {id}");
|
||||||
return Ok(true);
|
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