mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2024-11-21 21:48:21 -05:00
feat: CLOSED state on older versions if server not compatible
This commit is contained in:
parent
3269876e9f
commit
db8c8cef42
@ -39,9 +39,11 @@ namespace MyMcRealms.Controllers
|
||||
foreach (var world in AllServers.Servers)
|
||||
{
|
||||
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";
|
||||
|
||||
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),
|
||||
@ -49,7 +51,7 @@ namespace MyMcRealms.Controllers
|
||||
OwnerUUID = "069a79f444e94726a5befca90e38aaf5",
|
||||
Name = world.ServerName,
|
||||
Motd = world.Motd,
|
||||
State = "OPEN",
|
||||
State = isCompatibleOnOlderVersions,
|
||||
WorldType = "NORMAL",
|
||||
MaxPlayers = 10,
|
||||
MinigameId = null,
|
||||
|
Loading…
Reference in New Issue
Block a user