From 821e20d7080e876b05d7b2df6218c43766f5c560 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Wed, 31 Jan 2024 15:50:15 +0100 Subject: [PATCH] feat: GET /mco/available, GET /mco/client/compatible --- Minecraft-Realms-Emulator/Compatibility.cs | 9 +++++ .../Controllers/Mco/AvailableController.cs | 16 +++++++++ .../Mco/Client/CompatibleController.cs | 16 +++++++++ .../Controllers/WeatherForecastController.cs | 33 ------------------- .../Minecraft-Realms-Emulator.http | 6 +++- Minecraft-Realms-Emulator/WeatherForecast.cs | 13 -------- 6 files changed, 46 insertions(+), 47 deletions(-) create mode 100644 Minecraft-Realms-Emulator/Compatibility.cs create mode 100644 Minecraft-Realms-Emulator/Controllers/Mco/AvailableController.cs create mode 100644 Minecraft-Realms-Emulator/Controllers/Mco/Client/CompatibleController.cs delete mode 100644 Minecraft-Realms-Emulator/Controllers/WeatherForecastController.cs delete mode 100644 Minecraft-Realms-Emulator/WeatherForecast.cs diff --git a/Minecraft-Realms-Emulator/Compatibility.cs b/Minecraft-Realms-Emulator/Compatibility.cs new file mode 100644 index 0000000..9377d81 --- /dev/null +++ b/Minecraft-Realms-Emulator/Compatibility.cs @@ -0,0 +1,9 @@ +namespace Minecraft_Realms_Emulator +{ + public enum Compatility + { + COMPATIBLE, + OTHER, + OUTDATED + } +} diff --git a/Minecraft-Realms-Emulator/Controllers/Mco/AvailableController.cs b/Minecraft-Realms-Emulator/Controllers/Mco/AvailableController.cs new file mode 100644 index 0000000..21e08a9 --- /dev/null +++ b/Minecraft-Realms-Emulator/Controllers/Mco/AvailableController.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Minecraft_Realms_Emulator.Controllers.Mco +{ + [Route("mco/[controller]")] + [ApiController] + public class AvailableController : ControllerBase + { + [HttpGet(Name = "GetAvailable")] + public bool Get() + { + return true; + } + } +} diff --git a/Minecraft-Realms-Emulator/Controllers/Mco/Client/CompatibleController.cs b/Minecraft-Realms-Emulator/Controllers/Mco/Client/CompatibleController.cs new file mode 100644 index 0000000..751947d --- /dev/null +++ b/Minecraft-Realms-Emulator/Controllers/Mco/Client/CompatibleController.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Minecraft_Realms_Emulator.Controllers.Mco.Client +{ + [Route("/mco/client/[controller]")] + [ApiController] + public class CompatibleController : ControllerBase + { + [HttpGet(Name = "GetCompatible")] + public string Get() + { + return Compatility.COMPATIBLE.ToString(); + } + } +} diff --git a/Minecraft-Realms-Emulator/Controllers/WeatherForecastController.cs b/Minecraft-Realms-Emulator/Controllers/WeatherForecastController.cs deleted file mode 100644 index d997571..0000000 --- a/Minecraft-Realms-Emulator/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace Minecraft_Realms_Emulator.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} diff --git a/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.http b/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.http index bc29861..6374d25 100644 --- a/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.http +++ b/Minecraft-Realms-Emulator/Minecraft-Realms-Emulator.http @@ -1,6 +1,10 @@ @Minecraft_Realms_Emulator_HostAddress = http://localhost:8080 -GET {{Minecraft_Realms_Emulator_HostAddress}}/weatherforecast/ +GET {{Minecraft_Realms_Emulator_HostAddress}}/mco/available Accept: application/json ### + +GET {{Minecraft_Realms_Emulator_HostAddress}}/mco/client/compatible + +### \ No newline at end of file diff --git a/Minecraft-Realms-Emulator/WeatherForecast.cs b/Minecraft-Realms-Emulator/WeatherForecast.cs deleted file mode 100644 index af49903..0000000 --- a/Minecraft-Realms-Emulator/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Minecraft_Realms_Emulator -{ - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -}