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

fix: don't display a server to the player if they're not whitelisted or op

This commit is contained in:
CyberL1 2024-05-14 08:40:35 +02:00
parent fd688ebc5d
commit 6d1dd06d0f

View File

@ -17,6 +17,8 @@ namespace MyMcRealms.Controllers
{
string cookie = Request.Headers.Cookie;
string playerUUID = cookie.Split(";")[0].Split(":")[2];
string playerName = cookie.Split(";")[1].Split("=")[1];
string gameVerision = cookie.Split(";")[2].Split("=")[1];
List<WorldResponse> allWorlds = [];
@ -27,6 +29,11 @@ namespace MyMcRealms.Controllers
{
if (world.Online)
{
if (world.WhitelistEnable && !(world.Whitelist.Any(p => p.Uuid.Replace("-", "") == playerUUID) || world.Ops.Any(p => p.Uuid.Replace("-", "") == playerUUID)))
{
continue;
}
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";
@ -63,7 +70,7 @@ namespace MyMcRealms.Controllers
}
}
ServersResponse servers = new()
ServersResponse servers = new()
{
Servers = allWorlds
};