mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2024-11-21 13:38:21 -05:00
chore: fully rename project
This commit is contained in:
parent
ab05b999f8
commit
cf0ee17f0d
@ -1,11 +1,9 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Minecraft_Realms_Emulator.Responses;
|
|
||||||
using MyMcRealms.Attributes;
|
|
||||||
using MyMcRealms.MyMcAPI;
|
|
||||||
using MyMcRealms.Requests;
|
|
||||||
using MyMcRealms.Responses;
|
using MyMcRealms.Responses;
|
||||||
|
using MyMcRealms.Attributes;
|
||||||
|
using MyMcRealms.Requests;
|
||||||
|
|
||||||
namespace Minecraft_Realms_Emulator.Controllers
|
namespace MyMcRealms.Controllers
|
||||||
{
|
{
|
||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@ -20,7 +18,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
|
|
||||||
if (body.Name == playerName) return Forbid("You cannot invite yourself");
|
if (body.Name == playerName) return Forbid("You cannot invite yourself");
|
||||||
|
|
||||||
var _api = new MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
var _api = new MyMcAPI.Wrapper(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
var world = (await _api.GetAllServers()).Servers[wId];
|
var world = (await _api.GetAllServers()).Servers[wId];
|
||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
@ -30,7 +28,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
|
|
||||||
if (world.Whitelist.Any(p => p.Name == body.Name)) return BadRequest("Player already whitelisted");
|
if (world.Whitelist.Any(p => p.Name == body.Name)) return BadRequest("Player already whitelisted");
|
||||||
|
|
||||||
var api = new MyMcAPI(world.OwnersToken);
|
var api = new MyMcAPI.Wrapper(world.OwnersToken);
|
||||||
api.ExecuteCommand($"whitelist add {body.Name}");
|
api.ExecuteCommand($"whitelist add {body.Name}");
|
||||||
|
|
||||||
List<Player> whitelistedPlayers = [];
|
List<Player> whitelistedPlayers = [];
|
||||||
@ -90,7 +88,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
[HttpDelete("{wId}/invite/{uuid}")]
|
[HttpDelete("{wId}/invite/{uuid}")]
|
||||||
public async Task<ActionResult<bool>> DeleteInvite(int wId, string uuid)
|
public async Task<ActionResult<bool>> DeleteInvite(int wId, string uuid)
|
||||||
{
|
{
|
||||||
var _api = new MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
var _api = new MyMcAPI.Wrapper(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
var world = (await _api.GetAllServers()).Servers[wId];
|
var world = (await _api.GetAllServers()).Servers[wId];
|
||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
@ -102,7 +100,7 @@ namespace Minecraft_Realms_Emulator.Controllers
|
|||||||
|
|
||||||
if (!world.Whitelist.Any(p => p.Uuid.Replace("-", "") == uuid)) return BadRequest("Player not whitelisted");
|
if (!world.Whitelist.Any(p => p.Uuid.Replace("-", "") == uuid)) return BadRequest("Player not whitelisted");
|
||||||
|
|
||||||
var api = new MyMcAPI(world.OwnersToken);
|
var api = new MyMcAPI.Wrapper(world.OwnersToken);
|
||||||
api.ExecuteCommand($"whitelist remove {player.Name}");
|
api.ExecuteCommand($"whitelist remove {player.Name}");
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Minecraft_Realms_Emulator.Responses;
|
using MyMcRealms.Responses;
|
||||||
using MyMcRealms.Attributes;
|
using MyMcRealms.Attributes;
|
||||||
using MyMcRealms.MyMcAPI;
|
|
||||||
|
|
||||||
namespace Minecraft_Realms_Emulator.Controllers
|
namespace MyMcRealms.Controllers
|
||||||
{
|
{
|
||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@ -13,9 +12,9 @@ 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.Wrapper(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 api = new MyMcAPI.Wrapper(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);
|
||||||
@ -41,9 +40,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.Wrapper(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 api = new MyMcAPI.Wrapper(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);
|
||||||
|
@ -22,7 +22,7 @@ namespace MyMcRealms.Controllers
|
|||||||
|
|
||||||
List<WorldResponse> allWorlds = [];
|
List<WorldResponse> allWorlds = [];
|
||||||
|
|
||||||
AllServersResponse AllServers = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
AllServersResponse AllServers = await new MyMcAPI.Wrapper(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
||||||
|
|
||||||
foreach (var world in AllServers.Servers)
|
foreach (var world in AllServers.Servers)
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ namespace MyMcRealms.Controllers
|
|||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public async Task<ActionResult<WorldResponse>> GetWorldById(int id)
|
public async Task<ActionResult<WorldResponse>> GetWorldById(int id)
|
||||||
{
|
{
|
||||||
var worlds = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
var worlds = await new MyMcAPI.Wrapper(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
||||||
var world = worlds.Servers[id];
|
var world = worlds.Servers[id];
|
||||||
|
|
||||||
string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Owner" : world.Ops[0].Name;
|
string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Owner" : world.Ops[0].Name;
|
||||||
@ -134,10 +134,10 @@ 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 _api = new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
var _api = new MyMcAPI.Wrapper(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
|
|
||||||
var world = (await _api.GetAllServers()).Servers[id];
|
var world = (await _api.GetAllServers()).Servers[id];
|
||||||
var api = new MyMcAPI.MyMcAPI(world.OwnersToken);
|
var api = new MyMcAPI.Wrapper(world.OwnersToken);
|
||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
|
|
||||||
@ -149,10 +149,10 @@ 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 _api = new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
var _api = new MyMcAPI.Wrapper(Environment.GetEnvironmentVariable("MYMC_API_KEY"));
|
||||||
|
|
||||||
var world = (await _api.GetAllServers()).Servers[id];
|
var world = (await _api.GetAllServers()).Servers[id];
|
||||||
var api = new MyMcAPI.MyMcAPI(world.OwnersToken);
|
var api = new MyMcAPI.Wrapper(world.OwnersToken);
|
||||||
|
|
||||||
if (world == null) return NotFound("World not found");
|
if (world == null) return NotFound("World not found");
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ namespace MyMcRealms.Controllers
|
|||||||
[HttpGet("v1/{wId}/join/pc")]
|
[HttpGet("v1/{wId}/join/pc")]
|
||||||
public async Task<ActionResult<ConnectionResponse>> Join(int wId)
|
public async Task<ActionResult<ConnectionResponse>> Join(int wId)
|
||||||
{
|
{
|
||||||
AllServersResponse AllServers = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
AllServersResponse AllServers = await new MyMcAPI.Wrapper(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
||||||
|
|
||||||
ConnectionResponse connection = new()
|
ConnectionResponse connection = new()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
namespace MyMcRealms.MyMcAPI.Responses
|
|
||||||
{
|
|
||||||
public class ConsoleResponse
|
|
||||||
{
|
|
||||||
public bool Success { get; set; }
|
|
||||||
public string Message { get; set; } = null!;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace MyMcRealms.MyMcAPI.Responses
|
|
||||||
{
|
|
||||||
public class HelloResponse
|
|
||||||
{
|
|
||||||
public string Message { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace MyMcRealms.MyMcAPI
|
namespace MyMcRealms.MyMcAPI
|
||||||
{
|
{
|
||||||
public class MyMcAPI
|
public class Wrapper
|
||||||
{
|
{
|
||||||
private readonly string ApiUrl = "https://api.my-mc.link";
|
private readonly string ApiUrl = "https://api.my-mc.link";
|
||||||
private readonly HttpClient httpClient = new();
|
private readonly HttpClient httpClient = new();
|
||||||
|
|
||||||
public MyMcAPI(string apiKey)
|
public Wrapper(string apiKey)
|
||||||
{
|
{
|
||||||
httpClient.DefaultRequestHeaders.Add("x-my-mc-auth", apiKey);
|
httpClient.DefaultRequestHeaders.Add("x-my-mc-auth", apiKey);
|
||||||
httpClient.BaseAddress = new Uri(ApiUrl);
|
httpClient.BaseAddress = new Uri(ApiUrl);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Minecraft_Realms_Emulator.Responses
|
namespace MyMcRealms.Responses
|
||||||
{
|
{
|
||||||
public class MinecraftPlayerInfo
|
public class MinecraftPlayerInfo
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Minecraft_Realms_Emulator.Responses
|
namespace MyMcRealms.Responses
|
||||||
{
|
{
|
||||||
public class OpsResponse
|
public class OpsResponse
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user