1
0
mirror of https://github.com/CyberL1/MyMcRealms.git synced 2024-11-21 13:38:21 -05:00

feat: server online check

This commit is contained in:
CyberL1 2024-05-11 10:39:05 +02:00
parent 1a2d39ba2d
commit 8585ea1da4
2 changed files with 32 additions and 28 deletions

View File

@ -37,6 +37,8 @@ namespace MyMcRealms.Controllers
AllServersResponse AllServers = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
foreach (var world in AllServers.Servers)
{
if (world.Online)
{
int versionsCompared = SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse(world.GameVersion, SemVersionStyles.OptionalPatch));
string isCompatible = versionsCompared == 0 ? "COMPATIBLE" : versionsCompared < 0 ? "NEEDS_DOWNGRADE" : "NEEDS_UPGRADE";
@ -69,6 +71,7 @@ namespace MyMcRealms.Controllers
allWorlds.Add(response);
}
}
ServersResponse servers = new()
{

View File

@ -13,5 +13,6 @@ namespace MyMcRealms.MyMcAPI.Responses
public string Connect { get; set; } = string.Empty;
public string GameVersion { get; set; } = string.Empty;
public string Motd { get; set; } = string.Empty;
public bool Online { get; set; }
}
}