1
0
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:
CyberL1 2024-05-15 09:33:24 +02:00
parent ab05b999f8
commit cf0ee17f0d
8 changed files with 24 additions and 43 deletions

View File

@ -1,11 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Responses;
using MyMcRealms.Attributes;
using MyMcRealms.MyMcAPI;
using MyMcRealms.Requests;
using MyMcRealms.Responses;
using MyMcRealms.Attributes;
using MyMcRealms.Requests;
namespace Minecraft_Realms_Emulator.Controllers
namespace MyMcRealms.Controllers
{
[Route("[controller]")]
[ApiController]
@ -20,7 +18,7 @@ namespace Minecraft_Realms_Emulator.Controllers
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];
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");
var api = new MyMcAPI(world.OwnersToken);
var api = new MyMcAPI.Wrapper(world.OwnersToken);
api.ExecuteCommand($"whitelist add {body.Name}");
List<Player> whitelistedPlayers = [];
@ -90,7 +88,7 @@ namespace Minecraft_Realms_Emulator.Controllers
[HttpDelete("{wId}/invite/{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];
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");
var api = new MyMcAPI(world.OwnersToken);
var api = new MyMcAPI.Wrapper(world.OwnersToken);
api.ExecuteCommand($"whitelist remove {player.Name}");
return Ok(true);

View File

@ -1,9 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Responses;
using MyMcRealms.Responses;
using MyMcRealms.Attributes;
using MyMcRealms.MyMcAPI;
namespace Minecraft_Realms_Emulator.Controllers
namespace MyMcRealms.Controllers
{
[Route("[controller]")]
[ApiController]
@ -13,9 +12,9 @@ namespace Minecraft_Realms_Emulator.Controllers
[HttpPost("{wId}/{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 api = new MyMcAPI(world.OwnersToken);
var api = new MyMcAPI.Wrapper(world.OwnersToken);
var ops = world.Ops;
var player = world.Whitelist.Find(p => p.Uuid.Replace("-", "") == uuid);
@ -41,9 +40,9 @@ namespace Minecraft_Realms_Emulator.Controllers
[HttpDelete("{wId}/{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 api = new MyMcAPI(world.OwnersToken);
var api = new MyMcAPI.Wrapper(world.OwnersToken);
var ops = world.Ops;
var player = world.Whitelist.Find(p => p.Uuid.Replace("-", "") == uuid);

View File

@ -22,7 +22,7 @@ namespace MyMcRealms.Controllers
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)
{
@ -83,7 +83,7 @@ namespace MyMcRealms.Controllers
[HttpGet("{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];
string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Owner" : world.Ops[0].Name;
@ -134,10 +134,10 @@ namespace MyMcRealms.Controllers
[HttpPut("{id}/open")]
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 api = new MyMcAPI.MyMcAPI(world.OwnersToken);
var api = new MyMcAPI.Wrapper(world.OwnersToken);
if (world == null) return NotFound("World not found");
@ -149,10 +149,10 @@ namespace MyMcRealms.Controllers
[HttpPut("{id}/close")]
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 api = new MyMcAPI.MyMcAPI(world.OwnersToken);
var api = new MyMcAPI.Wrapper(world.OwnersToken);
if (world == null) return NotFound("World not found");
@ -164,7 +164,7 @@ namespace MyMcRealms.Controllers
[HttpGet("v1/{wId}/join/pc")]
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()
{

View File

@ -1,9 +0,0 @@

namespace MyMcRealms.MyMcAPI.Responses
{
public class ConsoleResponse
{
public bool Success { get; set; }
public string Message { get; set; } = null!;
}
}

View File

@ -1,7 +0,0 @@
namespace MyMcRealms.MyMcAPI.Responses
{
public class HelloResponse
{
public string Message { get; set; } = string.Empty;
}
}

View File

@ -2,12 +2,12 @@
namespace MyMcRealms.MyMcAPI
{
public class MyMcAPI
public class Wrapper
{
private readonly string ApiUrl = "https://api.my-mc.link";
private readonly HttpClient httpClient = new();
public MyMcAPI(string apiKey)
public Wrapper(string apiKey)
{
httpClient.DefaultRequestHeaders.Add("x-my-mc-auth", apiKey);
httpClient.BaseAddress = new Uri(ApiUrl);

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses
namespace MyMcRealms.Responses
{
public class MinecraftPlayerInfo
{

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses
namespace MyMcRealms.Responses
{
public class OpsResponse
{