1
0
mirror of https://github.com/CyberL1/MyMcRealms.git synced 2024-09-19 16:02:51 -04:00

fix: close worlds on older versions if the world's version is incompatible

This commit is contained in:
CyberL1 2024-09-08 20:59:06 +02:00
parent dbee1d819f
commit 5a93396138

View File

@ -39,14 +39,21 @@ namespace MyMcRealms.Controllers
string isCompatible = versionsCompared == 0 ? "COMPATIBLE" : versionsCompared < 0 ? "NEEDS_DOWNGRADE" : "NEEDS_UPGRADE"; 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; bool isOlderVersion = SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse("1.20.3", SemVersionStyles.OptionalPatch)) < 0;
//Console.WriteLine(isOlderVersion);
bool isCompatibleOnOlderVersions = isOlderVersion && !isCompatible.StartsWith("NEEDS_"); bool isCompatibleOnOlderVersions = isOlderVersion && !isCompatible.StartsWith("NEEDS_");
bool isBanned = world.Banlist.Any(p => p.Name == playerName); bool isBanned = world.Banlist.Any(p => p.Name == playerName);
Console.WriteLine(isCompatibleOnOlderVersions);
string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Owner" : world.Ops[0].Name; string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Owner" : world.Ops[0].Name;
string worldOwnerUuid = world.Ops.ToArray().Length == 0 ? "069a79f444e94726a5befca90e38aaf5" : world.Ops[0].Uuid; string worldOwnerUuid = world.Ops.ToArray().Length == 0 ? "069a79f444e94726a5befca90e38aaf5" : world.Ops[0].Uuid;
string worldName = world.Ops.ToArray().Length == 0 ? world.ServerName : $"{world.Ops[0].Name}'s server"; string worldName = world.Ops.ToArray().Length == 0 ? world.ServerName : $"{world.Ops[0].Name}'s server";
string worldState = isCompatibleOnOlderVersions || !isBanned ? "OPEN" : "CLOSED"; string worldState = !isBanned ? "OPEN" : "CLOSED";
if (!isCompatibleOnOlderVersions)
{
worldState = "CLOSED";
}
WorldResponse response = new() WorldResponse response = new()
{ {