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:
parent
1a2d39ba2d
commit
8585ea1da4
@ -38,36 +38,39 @@ namespace MyMcRealms.Controllers
|
|||||||
|
|
||||||
foreach (var world in AllServers.Servers)
|
foreach (var world in AllServers.Servers)
|
||||||
{
|
{
|
||||||
int versionsCompared = SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse(world.GameVersion, SemVersionStyles.OptionalPatch));
|
if (world.Online)
|
||||||
string isCompatible = versionsCompared == 0 ? "COMPATIBLE" : versionsCompared < 0 ? "NEEDS_DOWNGRADE" : "NEEDS_UPGRADE";
|
|
||||||
|
|
||||||
bool isOlderVersion = SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse("1.20.3", SemVersionStyles.OptionalPatch)) < 0;
|
|
||||||
string isCompatibleOnOlderVersions = (isOlderVersion && isCompatible.StartsWith("NEEDS_")) ? "CLOSED" : "OPEN";
|
|
||||||
|
|
||||||
WorldResponse response = new()
|
|
||||||
{
|
{
|
||||||
Id = AllServers.Servers.IndexOf(world),
|
int versionsCompared = SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse(world.GameVersion, SemVersionStyles.OptionalPatch));
|
||||||
Owner = "Owner",
|
string isCompatible = versionsCompared == 0 ? "COMPATIBLE" : versionsCompared < 0 ? "NEEDS_DOWNGRADE" : "NEEDS_UPGRADE";
|
||||||
OwnerUUID = "069a79f444e94726a5befca90e38aaf5",
|
|
||||||
Name = world.ServerName,
|
|
||||||
Motd = world.Motd,
|
|
||||||
State = isCompatibleOnOlderVersions,
|
|
||||||
WorldType = "NORMAL",
|
|
||||||
MaxPlayers = 10,
|
|
||||||
MinigameId = null,
|
|
||||||
MinigameName = null,
|
|
||||||
MinigameImage = null,
|
|
||||||
ActiveSlot = 1,
|
|
||||||
Member = false,
|
|
||||||
Players = [],
|
|
||||||
DaysLeft = 0,
|
|
||||||
Expired = false,
|
|
||||||
ExpiredTrial = false,
|
|
||||||
Compatibility = isCompatible,
|
|
||||||
ActiveVersion = world.GameVersion
|
|
||||||
};
|
|
||||||
|
|
||||||
allWorlds.Add(response);
|
bool isOlderVersion = SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse("1.20.3", SemVersionStyles.OptionalPatch)) < 0;
|
||||||
|
string isCompatibleOnOlderVersions = (isOlderVersion && isCompatible.StartsWith("NEEDS_")) ? "CLOSED" : "OPEN";
|
||||||
|
|
||||||
|
WorldResponse response = new()
|
||||||
|
{
|
||||||
|
Id = AllServers.Servers.IndexOf(world),
|
||||||
|
Owner = "Owner",
|
||||||
|
OwnerUUID = "069a79f444e94726a5befca90e38aaf5",
|
||||||
|
Name = world.ServerName,
|
||||||
|
Motd = world.Motd,
|
||||||
|
State = isCompatibleOnOlderVersions,
|
||||||
|
WorldType = "NORMAL",
|
||||||
|
MaxPlayers = 10,
|
||||||
|
MinigameId = null,
|
||||||
|
MinigameName = null,
|
||||||
|
MinigameImage = null,
|
||||||
|
ActiveSlot = 1,
|
||||||
|
Member = false,
|
||||||
|
Players = [],
|
||||||
|
DaysLeft = 0,
|
||||||
|
Expired = false,
|
||||||
|
ExpiredTrial = false,
|
||||||
|
Compatibility = isCompatible,
|
||||||
|
ActiveVersion = world.GameVersion
|
||||||
|
};
|
||||||
|
|
||||||
|
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