mirror of
https://github.com/CyberL1/MyMcRealms.git
synced 2025-07-26 21:00:28 -04:00
Compare commits
31 Commits
9fd092c730
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
434bb63eaf | ||
|
d0dea78769 | ||
|
b582001af5 | ||
|
ae166aba4d | ||
|
eb5f50be7b | ||
15af6a794a | |||
67d324971e | |||
0e06049d6e | |||
8f94aa8bdd | |||
ef35843140 | |||
2245a95d55 | |||
617ab4c11a | |||
88974eee33 | |||
6a7322943a | |||
29f3b9133f | |||
79c97c7415 | |||
9976c0bbb5 | |||
6e27e44746 | |||
7f7444249c | |||
abcf7b87e2 | |||
368e2c0e1b | |||
10c85cec19 | |||
44a86e2733 | |||
27f9435a6a | |||
49bb02f3cf | |||
0b4291e873 | |||
ecd0b3e020 | |||
5a93396138 | |||
3972d0eb05 | |||
377f45d492 | |||
dbee1d819f |
6
.github/workflows/deploy.yml
vendored
6
.github/workflows/deploy.yml
vendored
@@ -20,8 +20,8 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install sshpass
|
||||
- name: Stop the realms server for the deployment
|
||||
run: sshpass -p '${{ secrets.VPS_PASSWORD }}' ssh -o StrictHostKeyChecking=no cyber@my-mc.link "pm2 stop 0"
|
||||
run: sshpass -p '${{ secrets.VPS_PASSWORD }}' ssh -o StrictHostKeyChecking=no ${{ secrets.VPS_HOST }} -p ${{ secrets.VPS_PORT }} "pm2 stop 0"
|
||||
- name: Deploy compiled binary and dll files to server
|
||||
run: sshpass -p '${{ secrets.VPS_PASSWORD }}' scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r MyMcRealms/bin/Release/net8.0/linux-arm64/publish/* cyber@my-mc.link:/home/cyber/MyMcRealms
|
||||
run: sshpass -p '${{ secrets.VPS_PASSWORD }}' scp -P ${{ secrets.VPS_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r MyMcRealms/bin/Release/net8.0/linux-arm64/publish/* ${{ secrets.VPS_HOST }}:/home/cyber/MyMcRealms
|
||||
- name: Start the realms server again
|
||||
run: sshpass -p '${{ secrets.VPS_PASSWORD }}' ssh -o StrictHostKeyChecking=no cyber@my-mc.link "pm2 start 0"
|
||||
run: sshpass -p '${{ secrets.VPS_PASSWORD }}' ssh -o StrictHostKeyChecking=no ${{ secrets.VPS_HOST }} -p ${{ secrets.VPS_PORT }} "pm2 start 0"
|
||||
|
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)
|
||||
{
|
||||
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);
|
||||
|
||||
if (query == null) continue;
|
||||
|
@@ -45,7 +45,7 @@ namespace MyMcRealms.Controllers
|
||||
ErrorResponse errorResponse = new()
|
||||
{
|
||||
ErrorCode = 400,
|
||||
ErrorMsg = "Player already whitelisteed"
|
||||
ErrorMsg = "Player already whitelisted"
|
||||
};
|
||||
|
||||
return BadRequest(errorResponse);
|
||||
@@ -155,7 +155,7 @@ namespace MyMcRealms.Controllers
|
||||
ErrorResponse errorResponse = new()
|
||||
{
|
||||
ErrorCode = 400,
|
||||
ErrorMsg = "You with lmao"
|
||||
ErrorMsg = "You wish lmao"
|
||||
};
|
||||
|
||||
return BadRequest(errorResponse);
|
||||
|
@@ -18,7 +18,7 @@ namespace MyMcRealms.Controllers
|
||||
[HttpGet("client/compatible")]
|
||||
public string GetCompatible()
|
||||
{
|
||||
return Compatility.COMPATIBLE.ToString();
|
||||
return "COMPATIBLE";
|
||||
}
|
||||
|
||||
[HttpGet("v1/news")]
|
||||
@@ -26,7 +26,7 @@ namespace MyMcRealms.Controllers
|
||||
{
|
||||
var news = new NewsResponse
|
||||
{
|
||||
NewsLink = "https://github.com/CyberL1/Minecraft-Realms-Emulator",
|
||||
NewsLink = "https://github.com/CyberL1/MyMcRealms",
|
||||
};
|
||||
|
||||
return news;
|
||||
|
@@ -40,13 +40,33 @@ namespace MyMcRealms.Controllers
|
||||
|
||||
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);
|
||||
|
||||
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 worldOwnerName = world.Ops.ToArray().Length == 0 ? "Not claimed" : world.Ops[0].Name;
|
||||
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 worldState = isCompatibleOnOlderVersions || !isBanned ? "OPEN" : "CLOSED";
|
||||
string worldState = !isBanned ? "OPEN" : "CLOSED";
|
||||
|
||||
if (isOlderVersion && !isCompatibleOnOlderVersions)
|
||||
{
|
||||
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()
|
||||
{
|
||||
@@ -54,7 +74,8 @@ namespace MyMcRealms.Controllers
|
||||
Owner = worldOwnerName,
|
||||
OwnerUUID = worldOwnerUuid,
|
||||
Name = worldName,
|
||||
Motd = world.Motd,
|
||||
Motd = world.Motd.Replace("<22>", "§").Replace("&", "§"),
|
||||
IsHardcore = world.Hardcore,
|
||||
State = worldState,
|
||||
WorldType = "NORMAL",
|
||||
MaxPlayers = 10,
|
||||
@@ -70,6 +91,10 @@ namespace MyMcRealms.Controllers
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -104,9 +129,9 @@ namespace MyMcRealms.Controllers
|
||||
return BadRequest(errorResponse);
|
||||
}
|
||||
|
||||
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 worldName = world.Ops.ToArray().Length == 0 ? world.ServerName : $"{world.Ops[0].Name}'s server";
|
||||
string worldOwnerName = world.Ops[0].Name;
|
||||
string worldOwnerUuid = world.Ops[0].Uuid;
|
||||
string worldName = $"{world.Ops[0].Name}'s server";
|
||||
List<PlayerResponse> whitelistedPlayers = [];
|
||||
|
||||
foreach (var player in whitelist.Result)
|
||||
@@ -136,7 +161,8 @@ namespace MyMcRealms.Controllers
|
||||
Owner = worldOwnerName,
|
||||
OwnerUUID = worldOwnerUuid,
|
||||
Name = worldName,
|
||||
Motd = world.Motd,
|
||||
Motd = world.Motd.Replace("<22>", "§"),
|
||||
IsHardcore = world.Hardcore,
|
||||
State = whitelist.Enabled ? "CLOSED" : "OPEN",
|
||||
WorldType = "NORMAL",
|
||||
MaxPlayers = 10,
|
||||
@@ -165,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);
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@ namespace Minecraft_Realms_Emulator.Middlewares
|
||||
ErrorResponse errorResponse = new()
|
||||
{
|
||||
ErrorCode = 403,
|
||||
ErrorMsg = "This world isn't owner by anyone"
|
||||
ErrorMsg = "This world isn't owned by anyone"
|
||||
};
|
||||
|
||||
httpContext.Response.StatusCode = 403;
|
||||
|
@@ -18,6 +18,8 @@
|
||||
public List<Whitelist> Whitelist { get; set; } = null!;
|
||||
public bool WhitelistEnable { get; set; }
|
||||
public string OwnersToken { get; set; } = string.Empty;
|
||||
public string Gamemode { get; set; } = null!;
|
||||
public bool Hardcore { get; set; }
|
||||
}
|
||||
|
||||
public class Op
|
||||
|
@@ -8,10 +8,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNetEnv" Version="3.0.0" />
|
||||
<PackageReference Include="DotNetEnv" Version="3.1.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Semver" Version="2.3.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -3,6 +3,12 @@
|
||||
public class SlotResponse
|
||||
{
|
||||
public int SlotId { get; set; }
|
||||
public SlotSettingsResponse Settings { 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 int Id { get; set; }
|
||||
// public Subscription? Subscription { get; set; }
|
||||
public string? Owner { get; set; }
|
||||
public string? OwnerUUID { get; set; }
|
||||
public string? Name { 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 WorldType { get; set; } = "NORMAL";
|
||||
public List<PlayerResponse> Players { get; set; } = [];
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user