mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2024-11-21 21:48:21 -05:00
feat: server online check
This commit is contained in:
parent
1a2d39ba2d
commit
8585ea1da4
@ -37,6 +37,8 @@ namespace MyMcRealms.Controllers
|
|||||||
AllServersResponse AllServers = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
AllServersResponse AllServers = await new MyMcAPI.MyMcAPI(Environment.GetEnvironmentVariable("MYMC_API_KEY")).GetAllServers();
|
||||||
|
|
||||||
foreach (var world in AllServers.Servers)
|
foreach (var world in AllServers.Servers)
|
||||||
|
{
|
||||||
|
if (world.Online)
|
||||||
{
|
{
|
||||||
int versionsCompared = SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse(world.GameVersion, SemVersionStyles.OptionalPatch));
|
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";
|
string isCompatible = versionsCompared == 0 ? "COMPATIBLE" : versionsCompared < 0 ? "NEEDS_DOWNGRADE" : "NEEDS_UPGRADE";
|
||||||
@ -69,6 +71,7 @@ namespace MyMcRealms.Controllers
|
|||||||
|
|
||||||
allWorlds.Add(response);
|
allWorlds.Add(response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServersResponse servers = new()
|
ServersResponse servers = new()
|
||||||
{
|
{
|
||||||
|
@ -13,5 +13,6 @@ namespace MyMcRealms.MyMcAPI.Responses
|
|||||||
public string Connect { get; set; } = string.Empty;
|
public string Connect { get; set; } = string.Empty;
|
||||||
public string GameVersion { get; set; } = string.Empty;
|
public string GameVersion { get; set; } = string.Empty;
|
||||||
public string Motd { get; set; } = string.Empty;
|
public string Motd { get; set; } = string.Empty;
|
||||||
|
public bool Online { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user