mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2024-11-23 14:38:21 -05:00
feat: changing realm status changes the whitelist status
This commit is contained in:
parent
9115402ff1
commit
2dea13e5c9
@ -13,9 +13,10 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
[HttpPost("{wId}/{uuid}")]
|
[HttpPost("{wId}/{uuid}")]
|
||||||
public async Task<ActionResult<OpsResponse>> OpPlayer(int wId, string uuid)
|
public async Task<ActionResult<OpsResponse>> OpPlayer(int wId, string uuid)
|
||||||
{
|
{
|
||||||
var api = new MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
var _api = new MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
var world = (await api.GetAllServers()).Servers[wId];
|
var world = (await _api.GetAllServers()).Servers[wId];
|
||||||
|
var api = new MyMcAPI(world.OwnersToken);
|
||||||
|
|
||||||
var ops = world.Ops;
|
var ops = world.Ops;
|
||||||
var player = world.Whitelist.Find(p => p.Uuid.Replace("-", "") == uuid);
|
var player = world.Whitelist.Find(p => p.Uuid.Replace("-", "") == uuid);
|
||||||
|
|
||||||
@ -40,8 +41,9 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
[HttpDelete("{wId}/{uuid}")]
|
[HttpDelete("{wId}/{uuid}")]
|
||||||
public async Task<ActionResult<OpsResponse>> DeopPlayerAsync(int wId, string uuid)
|
public async Task<ActionResult<OpsResponse>> DeopPlayerAsync(int wId, string uuid)
|
||||||
{
|
{
|
||||||
var api = new MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
var _api = new MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
var world = (await api.GetAllServers()).Servers[wId];
|
var world = (await _api.GetAllServers()).Servers[wId];
|
||||||
|
var api = new MyMcAPI(world.OwnersToken);
|
||||||
|
|
||||||
var ops = world.Ops;
|
var ops = world.Ops;
|
||||||
var player = world.Whitelist.Find(p => p.Uuid.Replace("-", "") == uuid);
|
var player = world.Whitelist.Find(p => p.Uuid.Replace("-", "") == uuid);
|
||||||
|
@ -125,12 +125,14 @@ namespace MyMcRealms.Controllers
|
|||||||
[HttpPut("{id}/open")]
|
[HttpPut("{id}/open")]
|
||||||
public async Task<ActionResult<bool>> Open(int id)
|
public async Task<ActionResult<bool>> Open(int id)
|
||||||
{
|
{
|
||||||
var worlds = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
var _api = new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
var world = worlds.Servers[id];
|
|
||||||
|
var world = (await _api.GetAllServers()).Servers[id];
|
||||||
|
var api = new MyMcAPI.MyMcAPI(world.OwnersToken);
|
||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
|
|
||||||
// Turn off whitelist
|
api.ExecuteCommand("whitelist off");
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
@ -138,12 +140,14 @@ namespace MyMcRealms.Controllers
|
|||||||
[HttpPut("{id}/close")]
|
[HttpPut("{id}/close")]
|
||||||
public async Task<ActionResult<bool>> Close(int id)
|
public async Task<ActionResult<bool>> Close(int id)
|
||||||
{
|
{
|
||||||
var worlds = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
var _api = new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
var world = worlds.Servers[id];
|
|
||||||
|
var world = (await _api.GetAllServers()).Servers[id];
|
||||||
|
var api = new MyMcAPI.MyMcAPI(world.OwnersToken);
|
||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
|
|
||||||
// Turn on whitelist
|
api.ExecuteCommand("whitelist on");
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user