mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-11-09 16:08:21 -05:00
feat: world creating
This commit is contained in:
parent
94608fd792
commit
e02db741d6
@ -75,5 +75,32 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
|
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("{id}/initialize")]
|
||||||
|
public async Task<ActionResult<World>> Initialize(int id, WorldCreate body)
|
||||||
|
{
|
||||||
|
var worlds = await _context.Worlds.ToListAsync();
|
||||||
|
|
||||||
|
var world = worlds.Find(p => p.Id == id);
|
||||||
|
|
||||||
|
if (world == null) return NotFound("World not found");
|
||||||
|
if (world.State != State.UNINITIALIZED.ToString()) return NotFound("World already initialized");
|
||||||
|
|
||||||
|
world.Name = body.Name;
|
||||||
|
world.Motd = body.Description;
|
||||||
|
world.State = State.OPEN.ToString();
|
||||||
|
|
||||||
|
_context.Worlds.Update(world);
|
||||||
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
return Ok(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("{id}/reset")]
|
||||||
|
public ActionResult<World> Reset(int id)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Resetting world {id}");
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
Minecraft-Realms-Emulator/Entities/WorldCreate.cs
Normal file
8
Minecraft-Realms-Emulator/Entities/WorldCreate.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace Minecraft_Realms_Emulator.Entities
|
||||||
|
{
|
||||||
|
public class WorldCreate
|
||||||
|
{
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? Description { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user