mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2025-07-01 10:29:42 -04:00
Compare commits
20 Commits
49bb02f3cf
...
main
Author | SHA1 | Date | |
---|---|---|---|
eb5f50be7b | |||
15af6a794a | |||
67d324971e | |||
0e06049d6e | |||
8f94aa8bdd | |||
ef35843140 | |||
2245a95d55 | |||
617ab4c11a | |||
88974eee33 | |||
6a7322943a | |||
29f3b9133f | |||
79c97c7415 | |||
9976c0bbb5 | |||
6e27e44746 | |||
7f7444249c | |||
abcf7b87e2 | |||
368e2c0e1b | |||
10c85cec19 | |||
44a86e2733 | |||
27f9435a6a |
8
Gamemode.cs
Normal file
8
Gamemode.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
public enum Gamemode
|
||||||
|
{
|
||||||
|
survival,
|
||||||
|
creative,
|
||||||
|
adventure
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
namespace MyMcRealms
|
|
||||||
{
|
|
||||||
public enum Compatility
|
|
||||||
{
|
|
||||||
COMPATIBLE,
|
|
||||||
OTHER,
|
|
||||||
OUTDATED
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,6 +24,11 @@ namespace MyMcRealms.Controllers
|
|||||||
|
|
||||||
foreach (var world in allServers.Servers)
|
foreach (var world in allServers.Servers)
|
||||||
{
|
{
|
||||||
|
if (world.WhitelistEnable && !(world.Whitelist.Any(p => p.Uuid.Replace("-", "") == playerUUID) || world.Ops.Any(p => p.Uuid.Replace("-", "") == playerUUID)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var query = new MinecraftServerQuery().Query(world.Connect);
|
var query = new MinecraftServerQuery().Query(world.Connect);
|
||||||
|
|
||||||
if (query == null) continue;
|
if (query == null) continue;
|
||||||
|
@ -45,7 +45,7 @@ namespace MyMcRealms.Controllers
|
|||||||
ErrorResponse errorResponse = new()
|
ErrorResponse errorResponse = new()
|
||||||
{
|
{
|
||||||
ErrorCode = 400,
|
ErrorCode = 400,
|
||||||
ErrorMsg = "Player already whitelisteed"
|
ErrorMsg = "Player already whitelisted"
|
||||||
};
|
};
|
||||||
|
|
||||||
return BadRequest(errorResponse);
|
return BadRequest(errorResponse);
|
||||||
@ -155,7 +155,7 @@ namespace MyMcRealms.Controllers
|
|||||||
ErrorResponse errorResponse = new()
|
ErrorResponse errorResponse = new()
|
||||||
{
|
{
|
||||||
ErrorCode = 400,
|
ErrorCode = 400,
|
||||||
ErrorMsg = "You with lmao"
|
ErrorMsg = "You wish lmao"
|
||||||
};
|
};
|
||||||
|
|
||||||
return BadRequest(errorResponse);
|
return BadRequest(errorResponse);
|
||||||
|
@ -18,7 +18,7 @@ namespace MyMcRealms.Controllers
|
|||||||
[HttpGet("client/compatible")]
|
[HttpGet("client/compatible")]
|
||||||
public string GetCompatible()
|
public string GetCompatible()
|
||||||
{
|
{
|
||||||
return Compatility.COMPATIBLE.ToString();
|
return "COMPATIBLE";
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("v1/news")]
|
[HttpGet("v1/news")]
|
||||||
@ -26,7 +26,7 @@ namespace MyMcRealms.Controllers
|
|||||||
{
|
{
|
||||||
var news = new NewsResponse
|
var news = new NewsResponse
|
||||||
{
|
{
|
||||||
NewsLink = "https://github.com/CyberL1/Minecraft-Realms-Emulator",
|
NewsLink = "https://github.com/CyberL1/MyMcRealms",
|
||||||
};
|
};
|
||||||
|
|
||||||
return news;
|
return news;
|
||||||
|
@ -40,26 +40,42 @@ namespace MyMcRealms.Controllers
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
bool isCompatibleOnOlderVersions = isOlderVersion && !isCompatible.StartsWith("NEEDS_");
|
bool isCompatibleOnOlderVersions = isOlderVersion && isCompatible == "COMPATIBLE";
|
||||||
bool isBanned = world.Banlist.Any(p => p.Name == playerName);
|
bool isBanned = world.Banlist.Any(p => p.Name == playerName);
|
||||||
|
|
||||||
string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Owner" : world.Ops[0].Name;
|
string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Not claimed" : 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.Replace("-", "");
|
||||||
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 = !isBanned ? "OPEN" : "CLOSED";
|
string worldState = !isBanned ? "OPEN" : "CLOSED";
|
||||||
|
|
||||||
if (!isCompatibleOnOlderVersions)
|
if (isOlderVersion && !isCompatibleOnOlderVersions)
|
||||||
{
|
{
|
||||||
worldState = "CLOSED";
|
worldState = "CLOSED";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse("1.19.4", SemVersionStyles.OptionalPatch)) < 0)
|
||||||
|
{
|
||||||
|
if (world.Motd.Length > 32)
|
||||||
|
{
|
||||||
|
world.Motd = world.Motd.Remove(32); // Pre 1.19.4 MOTD limit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (world.Motd.Length > 52)
|
||||||
|
{
|
||||||
|
world.Motd = world.Motd.Remove(52); // Post 1.19.4 MOTD limit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WorldResponse response = new()
|
WorldResponse response = new()
|
||||||
{
|
{
|
||||||
Id = AllServers.Servers.IndexOf(world),
|
Id = AllServers.Servers.IndexOf(world),
|
||||||
Owner = worldOwnerName,
|
Owner = worldOwnerName,
|
||||||
OwnerUUID = worldOwnerUuid,
|
OwnerUUID = worldOwnerUuid,
|
||||||
Name = worldName,
|
Name = worldName,
|
||||||
Motd = world.Motd,
|
Motd = world.Motd.Replace("<22>", "§").Replace("&", "§"),
|
||||||
|
IsHardcore = world.Hardcore,
|
||||||
State = worldState,
|
State = worldState,
|
||||||
WorldType = "NORMAL",
|
WorldType = "NORMAL",
|
||||||
MaxPlayers = 10,
|
MaxPlayers = 10,
|
||||||
@ -75,6 +91,10 @@ namespace MyMcRealms.Controllers
|
|||||||
ActiveVersion = world.GameVersion
|
ActiveVersion = world.GameVersion
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (world.Gamemode == "survival") response.GameMode = 0;
|
||||||
|
if (world.Gamemode == "creative") response.GameMode = 1;
|
||||||
|
if (world.Gamemode == "adventure") response.GameMode = 2;
|
||||||
|
|
||||||
allWorlds.Add(response);
|
allWorlds.Add(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,9 +129,9 @@ namespace MyMcRealms.Controllers
|
|||||||
return BadRequest(errorResponse);
|
return BadRequest(errorResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
string worldOwnerName = world.Ops.ToArray().Length == 0 ? "Owner" : world.Ops[0].Name;
|
string worldOwnerName = world.Ops[0].Name;
|
||||||
string worldOwnerUuid = world.Ops.ToArray().Length == 0 ? "069a79f444e94726a5befca90e38aaf5" : world.Ops[0].Uuid;
|
string worldOwnerUuid = world.Ops[0].Uuid;
|
||||||
string worldName = world.Ops.ToArray().Length == 0 ? world.ServerName : $"{world.Ops[0].Name}'s server";
|
string worldName = $"{world.Ops[0].Name}'s server";
|
||||||
List<PlayerResponse> whitelistedPlayers = [];
|
List<PlayerResponse> whitelistedPlayers = [];
|
||||||
|
|
||||||
foreach (var player in whitelist.Result)
|
foreach (var player in whitelist.Result)
|
||||||
@ -141,7 +161,8 @@ namespace MyMcRealms.Controllers
|
|||||||
Owner = worldOwnerName,
|
Owner = worldOwnerName,
|
||||||
OwnerUUID = worldOwnerUuid,
|
OwnerUUID = worldOwnerUuid,
|
||||||
Name = worldName,
|
Name = worldName,
|
||||||
Motd = world.Motd,
|
Motd = world.Motd.Replace("<22>", "§"),
|
||||||
|
IsHardcore = world.Hardcore,
|
||||||
State = whitelist.Enabled ? "CLOSED" : "OPEN",
|
State = whitelist.Enabled ? "CLOSED" : "OPEN",
|
||||||
WorldType = "NORMAL",
|
WorldType = "NORMAL",
|
||||||
MaxPlayers = 10,
|
MaxPlayers = 10,
|
||||||
@ -170,6 +191,10 @@ namespace MyMcRealms.Controllers
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (world.Gamemode == "survival") response.GameMode = 0;
|
||||||
|
if (world.Gamemode == "creative") response.GameMode = 1;
|
||||||
|
if (world.Gamemode == "adventure") response.GameMode = 2;
|
||||||
|
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace Minecraft_Realms_Emulator.Middlewares
|
|||||||
ErrorResponse errorResponse = new()
|
ErrorResponse errorResponse = new()
|
||||||
{
|
{
|
||||||
ErrorCode = 403,
|
ErrorCode = 403,
|
||||||
ErrorMsg = "This world isn't owner by anyone"
|
ErrorMsg = "This world isn't owned by anyone"
|
||||||
};
|
};
|
||||||
|
|
||||||
httpContext.Response.StatusCode = 403;
|
httpContext.Response.StatusCode = 403;
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
public List<Whitelist> Whitelist { get; set; } = null!;
|
public List<Whitelist> Whitelist { get; set; } = null!;
|
||||||
public bool WhitelistEnable { get; set; }
|
public bool WhitelistEnable { get; set; }
|
||||||
public string OwnersToken { get; set; } = string.Empty;
|
public string OwnersToken { get; set; } = string.Empty;
|
||||||
|
public string Gamemode { get; set; } = null!;
|
||||||
|
public bool Hardcore { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Op
|
public class Op
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<PackageReference Include="DotNetEnv" Version="3.1.1" />
|
<PackageReference Include="DotNetEnv" Version="3.1.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Semver" Version="2.3.0" />
|
<PackageReference Include="Semver" Version="2.3.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -3,6 +3,12 @@
|
|||||||
public class SlotResponse
|
public class SlotResponse
|
||||||
{
|
{
|
||||||
public int SlotId { get; set; }
|
public int SlotId { get; set; }
|
||||||
|
public SlotSettingsResponse Settings { get; set; } = null!;
|
||||||
public string Options { get; set; } = null!;
|
public string Options { get; set; } = null!;
|
||||||
|
|
||||||
|
public SlotResponse()
|
||||||
|
{
|
||||||
|
Settings = new SlotSettingsResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
7
MyMcRealms/Responses/SlotSettingsResponse.cs
Normal file
7
MyMcRealms/Responses/SlotSettingsResponse.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace MyMcRealms.Responses
|
||||||
|
{
|
||||||
|
public class SlotSettingsResponse
|
||||||
|
{
|
||||||
|
public bool Hardcore = false;
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,14 @@
|
|||||||
using System.Text.Json;
|
namespace MyMcRealms.Responses
|
||||||
|
|
||||||
namespace MyMcRealms.Responses
|
|
||||||
{
|
{
|
||||||
public class WorldResponse
|
public class WorldResponse
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
// public Subscription? Subscription { get; set; }
|
|
||||||
public string? Owner { get; set; }
|
public string? Owner { get; set; }
|
||||||
public string? OwnerUUID { get; set; }
|
public string? OwnerUUID { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public string? Motd { get; set; }
|
public string? Motd { get; set; }
|
||||||
|
public int GameMode { get; set; }
|
||||||
|
public bool IsHardcore { get; set; }
|
||||||
public string State { get; set; } = "OPEN";
|
public string State { get; set; } = "OPEN";
|
||||||
public string WorldType { get; set; } = "NORMAL";
|
public string WorldType { get; set; } = "NORMAL";
|
||||||
public List<PlayerResponse> Players { get; set; } = [];
|
public List<PlayerResponse> Players { get; set; } = [];
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user