Compare commits

..

24 Commits

Author SHA1 Message Date
ff325cf5f6 fix: update game version on slot if server has updates enabled 2024-12-19 21:06:02 +01:00
484d12463a feat: update server on start 2024-12-19 15:08:41 +01:00
0a89b6ade1 fix: logs in admin panel 2024-12-18 14:00:05 +01:00
967518dc71 oops 2024-12-14 19:36:38 +01:00
1dc7194888 fix: wait until the server is closed before returning 2024-12-14 19:30:06 +01:00
84548585ac refactor: move WorkMode setting to environment variable 2024-12-14 15:07:42 +01:00
f1a5ddd98c chore: remove non-related routes from external mode 2024-12-14 14:58:57 +01:00
6cb43fcaa3 fix: force delete server container on realm deletion 2024-12-14 14:06:30 +01:00
27a5d20888 fix: uninitialized worlds 2024-12-14 13:52:45 +01:00
b0ed4a50de fix: include minigame data on all world routes 2024-12-13 21:44:51 +01:00
8c72940c23 fix: minigane name on world configuration screen 2024-12-13 21:41:33 +01:00
4605ac5fef fix: world slots 2024-12-13 21:16:34 +01:00
54a05537c4 refactor: fix motd showing as "..." on minecraft >1.21.1, SlotsResponse.Options now has proper typing 2024-12-09 23:05:35 +01:00
d302ea46e2 refactor: move shared code to Shared directory 2024-12-09 14:30:18 +01:00
92a9177d1f create unit tests 2024-10-20 20:49:15 +02:00
c2f62fdffb fix: check if world is initialized 2024-10-20 14:26:30 +02:00
83c43ce73d make remoteSubscriptionId dummy 2024-10-20 14:22:47 +02:00
9f64fb6c82 fix: don't create world in /{wId}/createPrereleaseRealm route 2024-09-30 13:28:18 +02:00
71db9fc549 chore: update packages 2024-09-29 18:51:55 +02:00
3f100aadf6 chore: update packages 2024-08-30 09:04:47 +02:00
3ef9962bac chore: update packages 2024-07-31 16:52:52 +02:00
22ee98584b feat(sevrer): use stop command for the StopServer function 2024-07-16 17:41:21 +02:00
de45bf843e fix(server): updating realm with empty description should work now 2024-07-14 21:07:49 +02:00
f133c237ef feat(server): Get server's address from its MOTD in external mode 2024-07-14 18:16:15 +02:00
109 changed files with 617 additions and 511 deletions

View File

@ -5,7 +5,9 @@ VisualStudioVersion = 17.8.34511.84
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Minecraft-Realms-Emulator", "Minecraft-Realms-Emulator\Minecraft-Realms-Emulator.csproj", "{A9A21AAF-EF1B-4723-9407-51FD6B831B98}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Minecraft-Realms-Emulator", "Minecraft-Realms-Emulator\Minecraft-Realms-Emulator.csproj", "{A9A21AAF-EF1B-4723-9407-51FD6B831B98}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Panel", "Panel\Panel.csproj", "{DDDF0FE0-736D-47D5-8571-3DD7354B7917}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Panel", "Panel\Panel.csproj", "{DDDF0FE0-736D-47D5-8571-3DD7354B7917}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{AFF83C8C-B6CA-4707-A26E-82002822F820}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -21,6 +23,10 @@ Global
{DDDF0FE0-736D-47D5-8571-3DD7354B7917}.Debug|Any CPU.Build.0 = Debug|Any CPU {DDDF0FE0-736D-47D5-8571-3DD7354B7917}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDDF0FE0-736D-47D5-8571-3DD7354B7917}.Release|Any CPU.ActiveCfg = Release|Any CPU {DDDF0FE0-736D-47D5-8571-3DD7354B7917}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDDF0FE0-736D-47D5-8571-3DD7354B7917}.Release|Any CPU.Build.0 = Release|Any CPU {DDDF0FE0-736D-47D5-8571-3DD7354B7917}.Release|Any CPU.Build.0 = Release|Any CPU
{AFF83C8C-B6CA-4707-A26E-82002822F820}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFF83C8C-B6CA-4707-A26E-82002822F820}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFF83C8C-B6CA-4707-A26E-82002822F820}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFF83C8C-B6CA-4707-A26E-82002822F820}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -4,7 +4,7 @@ using System.Text.Json;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable

View File

@ -14,15 +14,19 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DotNetEnv" Version="3.0.0" /> <PackageReference Include="DotNetEnv" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.8" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="UnitTests" />
</ItemGroup>
</Project> </Project>

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
{ {

View File

@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Requests; using Minecraft_Realms_Emulator.Shared.Requests;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
{ {

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Enums; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
{ {

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Enums; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Data;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
{ {

View File

@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Enums; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Requests; using Minecraft_Realms_Emulator.Shared.Requests;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Modes.External namespace Minecraft_Realms_Emulator.Modes.External
@ -73,6 +73,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot?.GameMode ?? 0,
IsHardcore = activeSlot?.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -114,6 +116,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -154,8 +158,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
string playerName = cookie.Split(";")[1].Split("=")[1]; string playerName = cookie.Split(";")[1].Split("=")[1];
string gameVersion = cookie.Split(";")[2].Split("=")[1]; string gameVersion = cookie.Split(";")[2].Split("=")[1];
var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID || w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld).ToListAsync(); var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID || w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.Minigame).Include(w => w.ParentWorld).ToListAsync();
var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Select(p => p.World).ToListAsync(); var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Include(p => p.World.Minigame).Select(p => p.World).ToListAsync();
List<WorldResponse> allWorlds = []; List<WorldResponse> allWorlds = [];
@ -173,6 +177,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot?.GameMode ?? 0,
IsHardcore = activeSlot?.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -227,6 +233,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -280,8 +288,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
string playerName = cookie.Split(";")[1].Split("=")[1]; string playerName = cookie.Split(";")[1].Split("=")[1];
string gameVersion = cookie.Split(";")[2].Split("=")[1]; string gameVersion = cookie.Split(";")[2].Split("=")[1];
var ownedWorlds = await _context.Worlds.Where(w => w.ParentWorld != null && w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld).ToListAsync(); var ownedWorlds = await _context.Worlds.Where(w => w.ParentWorld != null && w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld).Include(w => w.Minigame).ToListAsync();
var memberWorlds = await _context.Players.Where(p => p.World.ParentWorld != null && p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Select(p => p.World).ToListAsync(); var memberWorlds = await _context.Players.Where(p => p.World.ParentWorld != null && p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Include(p => p.World.Minigame).Select(p => p.World).ToListAsync();
List<WorldResponse> allWorlds = []; List<WorldResponse> allWorlds = [];
@ -325,6 +333,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot?.GameMode ?? 0,
IsHardcore = activeSlot?.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -368,6 +378,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -407,7 +419,18 @@ namespace Minecraft_Realms_Emulator.Modes.External
string cookie = Request.Headers.Cookie; string cookie = Request.Headers.Cookie;
string gameVersion = cookie.Split(";")[2].Split("=")[1]; string gameVersion = cookie.Split(";")[2].Split("=")[1];
var world = await _context.Worlds.Include(w => w.Players).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld.Subscription).FirstOrDefaultAsync(w => w.Id == wId); var world = await _context.Worlds.Include(w => w.Players).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld.Subscription).Include(w => w.Minigame).FirstOrDefaultAsync(w => w.Id == wId);
if (world.State == nameof(StateEnum.UNINITIALIZED))
{
ErrorResponse error = new()
{
ErrorCode = 400,
ErrorMsg = "Initialize the world first"
};
return StatusCode(400, error);
}
Slot activeSlot = world.Slots.Find(s => s.SlotId == world.ActiveSlot); Slot activeSlot = world.Slots.Find(s => s.SlotId == world.ActiveSlot);
@ -425,8 +448,9 @@ namespace Minecraft_Realms_Emulator.Modes.External
{ {
slotName = slot.SlotName, slotName = slot.SlotName,
gameMode = slot.GameMode, gameMode = slot.GameMode,
hardcore = slot.Difficulty == 3,
difficulty = slot.Difficulty, difficulty = slot.Difficulty,
spawnProtection = slot.SpawnProtection, spawnProection = slot.SpawnProtection,
forceGameMode = slot.ForceGameMode, forceGameMode = slot.ForceGameMode,
pvp = slot.Pvp, pvp = slot.Pvp,
spawnAnimals = slot.SpawnAnimals, spawnAnimals = slot.SpawnAnimals,
@ -453,6 +477,8 @@ namespace Minecraft_Realms_Emulator.Modes.External
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.GameMode == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -517,7 +543,6 @@ namespace Minecraft_Realms_Emulator.Modes.External
var connection = new Connection var connection = new Connection
{ {
World = world, World = world,
Address = defaultServerAddress.Value
}; };
Slot slot = new() Slot slot = new()
@ -582,55 +607,9 @@ namespace Minecraft_Realms_Emulator.Modes.External
return StatusCode(401, errorResponse); return StatusCode(401, errorResponse);
} }
world.Name = $"[PRE] {world.ParentWorld.Name}";
world.Motd = $"[PRE] {world.ParentWorld.Motd}";
world.State = nameof(StateEnum.OPEN);
var config = new ConfigHelper(_context);
var defaultServerAddress = config.GetSetting(nameof(SettingsEnum.DefaultServerAddress));
var connection = new Connection
{
World = world,
Address = defaultServerAddress.Value
};
Slot slot = new()
{
World = world,
SlotId = 1,
SlotName = "",
Version = gameVersion,
GameMode = 0,
Difficulty = 2,
SpawnProtection = 0,
ForceGameMode = false,
Pvp = true,
SpawnAnimals = true,
SpawnMonsters = true,
SpawnNPCs = true,
CommandBlocks = false
};
_context.Worlds.Update(world);
_context.Connections.Add(connection);
_context.Slots.Add(slot);
_context.SaveChanges();
return Ok(world); return Ok(world);
} }
[HttpPost("{wId}/reset")]
[CheckForWorld]
[CheckRealmOwner]
public ActionResult<bool> Reset(int wId)
{
Console.WriteLine($"Resetting world {wId}");
return Ok(true);
}
[HttpPut("{wId}/open")] [HttpPut("{wId}/open")]
[CheckForWorld] [CheckForWorld]
[CheckRealmOwner] [CheckRealmOwner]
@ -679,7 +658,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
return BadRequest(errorResponse); return BadRequest(errorResponse);
} }
if (body.Description.Length > 32) if (body.Description?.Length > 32)
{ {
ErrorResponse errorResponse = new() ErrorResponse errorResponse = new()
{ {
@ -702,130 +681,13 @@ namespace Minecraft_Realms_Emulator.Modes.External
return Ok(true); return Ok(true);
} }
[HttpPost("{wId}/slot/{sId}")]
[CheckForWorld]
[CheckRealmOwner]
public async Task<ActionResult<(bool, ErrorResponse)>> UpdateSlot(int wId, int sId, SlotOptionsRequest body)
{
if (body.SlotName.Length > 10)
{
ErrorResponse errorResponse = new()
{
ErrorCode = 400,
ErrorMsg = "Slot name cannot exceed 10 characters"
};
return BadRequest(errorResponse);
}
var slots = await _context.Slots.Where(s => s.World.Id == wId).ToListAsync();
var slot = slots.Find(s => s.SlotId == sId);
slot.SlotName = body.SlotName;
slot.GameMode = body.GameMode;
slot.Difficulty = body.Difficulty;
slot.SpawnProtection = body.SpawnProtection;
slot.ForceGameMode = body.ForceGameMode;
slot.Pvp = body.Pvp;
slot.SpawnAnimals = body.SpawnAnimals;
slot.SpawnMonsters = body.SpawnMonsters;
slot.SpawnNPCs = body.SpawnNPCs;
slot.CommandBlocks = body.CommandBlocks;
_context.SaveChanges();
return Ok(true);
}
[HttpPut("{wId}/slot/{sId}")]
[CheckForWorld]
[CheckRealmOwner]
public ActionResult<bool> SwitchSlot(int wId, int sId)
{
var world = _context.Worlds.Include(w => w.Minigame).FirstOrDefault(w => w.Id == wId);
var slot = _context.Slots.Where(s => s.World.Id == wId).Where(s => s.SlotId == sId).Any();
if (!slot)
{
string cookie = Request.Headers.Cookie;
string gameVersion = cookie.Split(";")[2].Split("=")[1];
_context.Slots.Add(new()
{
World = world,
SlotId = sId,
SlotName = "",
Version = gameVersion,
GameMode = 0,
Difficulty = 2,
SpawnProtection = 0,
ForceGameMode = false,
Pvp = true,
SpawnAnimals = true,
SpawnMonsters = true,
SpawnNPCs = true,
CommandBlocks = false
});
_context.SaveChanges();
}
world.ActiveSlot = sId;
world.Minigame = null;
world.WorldType = nameof(WorldTypeEnum.NORMAL);
_context.SaveChanges();
return Ok(true);
}
[HttpGet("{wId}/backups")]
[CheckForWorld]
[CheckRealmOwner]
public async Task<ActionResult<BackupsResponse>> GetBackups(int wId)
{
var backups = await _context.Backups.Where(b => b.Slot.World.Id == wId).ToListAsync();
BackupsResponse worldBackups = new()
{
Backups = backups
};
return Ok(worldBackups);
}
[HttpGet("{wId}/slot/{sId}/download")]
[CheckForWorld]
[CheckRealmOwner]
public ActionResult<BackupDownloadResponse> GetBackup(int wId, int sId)
{
Backup backup = _context.Backups.Include(b => b.Slot).FirstOrDefault(b => b.Slot.World.Id == wId && b.Slot.Id == sId);
if (backup == null)
{
ErrorResponse errorResponse = new()
{
ErrorCode = 404,
ErrorMsg = "No backup found"
};
return NotFound(errorResponse);
}
BackupDownloadResponse backupDownloadResponse = new()
{
DownloadLink = backup.DownloadUrl,
ResourcePackUrl = backup.ResourcePackUrl,
ResourcePackHash = backup.ResourcePackHash,
};
return Ok(backupDownloadResponse);
}
[HttpGet("v1/{wId}/join/pc")] [HttpGet("v1/{wId}/join/pc")]
public ActionResult<Connection> Join(int wId) public ActionResult<Connection> Join(int wId)
{ {
var connection = _context.Connections.FirstOrDefault(x => x.World.Id == wId); var connection = _context.Connections.Include(c => c.World).FirstOrDefault(x => x.World.Id == wId);
// Set the server's addrees to its MOTD
connection.Address = connection.World.Motd;
return Ok(connection); return Ok(connection);
} }
@ -856,38 +718,5 @@ namespace Minecraft_Realms_Emulator.Modes.External
return Ok(true); return Ok(true);
} }
[HttpGet("templates/{type}")]
public ActionResult<TemplatesResponse> GetWorldTemplates(string type, int page, int pageSize)
{
var totalTemplates = _context.Templates.Where(t => t.Type == type).Count();
var templates = _context.Templates.Where(t => t.Type == type).Skip((page - 1) * pageSize).Take(pageSize).ToList();
TemplatesResponse templatesResponse = new()
{
Page = page,
Size = pageSize,
Total = totalTemplates,
Templates = templates
};
return Ok(templatesResponse);
}
[HttpPut("minigames/{mId}/{wId}")]
[CheckForWorld]
[CheckRealmOwner]
public ActionResult<bool> SwitchToMinigame(int mId, int wId)
{
var world = _context.Worlds.Find(wId);
var minigame = _context.Templates.FirstOrDefault(t => t.Type == nameof(WorldTemplateTypeEnum.MINIGAME) && t.Id == mId);
world.Minigame = minigame;
world.WorldType = nameof(WorldTypeEnum.MINIGAME);
_context.SaveChanges();
return Ok(true);
}
} }
} }

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Enums; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Modes.Realms namespace Minecraft_Realms_Emulator.Modes.Realms

View File

@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Requests; using Minecraft_Realms_Emulator.Shared.Requests;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Enums; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Enums; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Data;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {

View File

@ -1,16 +1,16 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Enums;
using Minecraft_Realms_Emulator.Helpers;
using Minecraft_Realms_Emulator.Modes.Realms.Helpers; using Minecraft_Realms_Emulator.Modes.Realms.Helpers;
using Minecraft_Realms_Emulator.Requests; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Entities;
using Newtonsoft.Json; using Minecraft_Realms_Emulator.Shared.Requests;
using Minecraft_Realms_Emulator.Shared.Responses;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {
@ -76,6 +76,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot?.GameMode ?? 0,
IsHardcore = activeSlot?.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -117,6 +119,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -157,8 +161,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
string playerName = cookie.Split(";")[1].Split("=")[1]; string playerName = cookie.Split(";")[1].Split("=")[1];
string gameVersion = cookie.Split(";")[2].Split("=")[1]; string gameVersion = cookie.Split(";")[2].Split("=")[1];
var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID || w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld).ToListAsync(); var ownedWorlds = await _context.Worlds.Where(w => w.OwnerUUID == playerUUID || w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.Minigame).Include(w => w.ParentWorld).ToListAsync();
var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Select(p => p.World).ToListAsync(); var memberWorlds = await _context.Players.Where(p => p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Include(p => p.World.Minigame).Select(p => p.World).ToListAsync();
List<WorldResponse> allWorlds = []; List<WorldResponse> allWorlds = [];
@ -176,6 +180,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot?.GameMode ?? 0,
IsHardcore = activeSlot?.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -230,6 +236,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -283,8 +291,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
string playerName = cookie.Split(";")[1].Split("=")[1]; string playerName = cookie.Split(";")[1].Split("=")[1];
string gameVersion = cookie.Split(";")[2].Split("=")[1]; string gameVersion = cookie.Split(";")[2].Split("=")[1];
var ownedWorlds = await _context.Worlds.Where(w => w.ParentWorld != null && w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld).ToListAsync(); var ownedWorlds = await _context.Worlds.Where(w => w.ParentWorld != null && w.ParentWorld.OwnerUUID == playerUUID).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld).Include(w => w.Minigame).ToListAsync();
var memberWorlds = await _context.Players.Where(p => p.World.ParentWorld != null && p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Select(p => p.World).ToListAsync(); var memberWorlds = await _context.Players.Where(p => p.World.ParentWorld != null && p.Uuid == playerUUID && p.Accepted).Include(p => p.World.Subscription).Include(p => p.World.Slots).Include(p => p.World.ParentWorld).Include(p => p.World.Minigame).Select(p => p.World).ToListAsync();
List<WorldResponse> allWorlds = []; List<WorldResponse> allWorlds = [];
@ -328,6 +336,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot?.GameMode ?? 0,
IsHardcore = activeSlot?.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -371,6 +381,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -412,6 +424,17 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
var world = await _context.Worlds.Include(w => w.Players).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld.Subscription).FirstOrDefaultAsync(w => w.Id == wId); var world = await _context.Worlds.Include(w => w.Players).Include(w => w.Subscription).Include(w => w.Slots).Include(w => w.ParentWorld.Subscription).FirstOrDefaultAsync(w => w.Id == wId);
if (world.State == nameof(StateEnum.UNINITIALIZED))
{
ErrorResponse error = new()
{
ErrorCode = 400,
ErrorMsg = "Initialize the world first"
};
return StatusCode(400, error);
}
Slot activeSlot = world.Slots.Find(s => s.SlotId == world.ActiveSlot); Slot activeSlot = world.Slots.Find(s => s.SlotId == world.ActiveSlot);
List<SlotResponse> slots = []; List<SlotResponse> slots = [];
@ -428,8 +451,9 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{ {
slotName = slot.SlotName, slotName = slot.SlotName,
gameMode = slot.GameMode, gameMode = slot.GameMode,
hardcore = slot.Difficulty == 3,
difficulty = slot.Difficulty, difficulty = slot.Difficulty,
spawnProtection = slot.SpawnProtection, spawnProection = slot.SpawnProtection,
forceGameMode = slot.ForceGameMode, forceGameMode = slot.ForceGameMode,
pvp = slot.Pvp, pvp = slot.Pvp,
spawnAnimals = slot.SpawnAnimals, spawnAnimals = slot.SpawnAnimals,
@ -456,6 +480,8 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
OwnerUUID = world.OwnerUUID, OwnerUUID = world.OwnerUUID,
Name = world.Name, Name = world.Name,
Motd = world.Motd, Motd = world.Motd,
GameMode = activeSlot.GameMode,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State, State = world.State,
WorldType = world.WorldType, WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers, MaxPlayers = world.MaxPlayers,
@ -597,56 +623,6 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
return StatusCode(401, errorResponse); return StatusCode(401, errorResponse);
} }
world.Name = $"[PRE] {world.ParentWorld.Name}";
world.Motd = $"[PRE] {world.ParentWorld.Motd}";
world.State = nameof(StateEnum.OPEN);
var config = new ConfigHelper(_context);
var defaultServerAddress = config.GetSetting(nameof(SettingsEnum.DefaultServerAddress));
static int FindFreeTcpPort()
{
TcpListener l = new(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
}
var port = FindFreeTcpPort();
var connection = new Connection
{
World = world,
Address = $"{defaultServerAddress.Value}:{port}"
};
new DockerHelper(world).CreateServer(port);
Slot slot = new()
{
World = world,
SlotId = 1,
SlotName = "",
Version = gameVersion,
GameMode = 0,
Difficulty = 2,
SpawnProtection = 0,
ForceGameMode = false,
Pvp = true,
SpawnAnimals = true,
SpawnMonsters = true,
SpawnNPCs = true,
CommandBlocks = false
};
_context.Worlds.Update(world);
_context.Connections.Add(connection);
_context.Slots.Add(slot);
_context.SaveChanges();
return Ok(world); return Ok(world);
} }
@ -711,6 +687,15 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
_context.SaveChanges(); _context.SaveChanges();
var connection = _context.Connections.FirstOrDefault(c => c.World.Id == wId);
var query = new MinecraftServerQuery().Query(connection.Address);
while (query != null)
{
await Task.Delay(1000);
query = new MinecraftServerQuery().Query(connection.Address);
}
return Ok(true); return Ok(true);
} }
@ -731,7 +716,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
return BadRequest(errorResponse); return BadRequest(errorResponse);
} }
if (body.Description.Length > 32) if (body.Description?.Length > 32)
{ {
ErrorResponse errorResponse = new() ErrorResponse errorResponse = new()
{ {
@ -917,7 +902,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
[HttpGet("v1/{wId}/join/pc")] [HttpGet("v1/{wId}/join/pc")]
public async Task<ActionResult<Connection>> Join(int wId) public async Task<ActionResult<Connection>> Join(int wId)
{ {
var connection = _context.Connections.Include(c => c.World).FirstOrDefault(x => x.World.Id == wId); var connection = _context.Connections.Include(c => c.World).Include(c => c.World.Slots).FirstOrDefault(x => x.World.Id == wId);
var isRunning = new DockerHelper(connection.World).IsRunning(); var isRunning = new DockerHelper(connection.World).IsRunning();
var query = new MinecraftServerQuery().Query(connection.Address); var query = new MinecraftServerQuery().Query(connection.Address);
@ -933,7 +918,17 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
query = new MinecraftServerQuery().Query(connection.Address); query = new MinecraftServerQuery().Query(connection.Address);
} }
Slot activeSlot = connection.World.Slots.Find(s => s.SlotId == connection.World.ActiveSlot);
string cookie = Request.Headers.Cookie; string cookie = Request.Headers.Cookie;
string gameVersion = cookie.Split(";")[2].Split("=")[1];
if (new MinecraftVersionParser.MinecraftVersion(activeSlot.Version).CompareTo(new MinecraftVersionParser.MinecraftVersion(gameVersion)) < 0 && new DockerHelper(connection.World).RunCommand("! test -f .no-update") == 0)
{
activeSlot.Version = gameVersion;
_context.SaveChanges();
}
string playerUUID = cookie.Split(";")[0].Split(":")[2]; string playerUUID = cookie.Split(";")[0].Split(":")[2];
if (connection.World.OwnerUUID == playerUUID) if (connection.World.OwnerUUID == playerUUID)

View File

@ -1,4 +1,4 @@
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
using System.Diagnostics; using System.Diagnostics;
namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
@ -48,14 +48,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
public void StopServer() public void StopServer()
{ {
ProcessStartInfo serverProcessInfo = new(); ExecuteCommand("stop");
serverProcessInfo.FileName = "docker";
serverProcessInfo.Arguments = $"container stop realm-server-{world.Id}";
Process serverProcess = new();
serverProcess.StartInfo = serverProcessInfo;
serverProcess.Start();
} }
public void RebootServer() public void RebootServer()
@ -75,7 +68,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
ProcessStartInfo serverProcessInfo = new(); ProcessStartInfo serverProcessInfo = new();
serverProcessInfo.FileName = "docker"; serverProcessInfo.FileName = "docker";
serverProcessInfo.Arguments = $"container rm realm-server-{world.Id}"; serverProcessInfo.Arguments = $"container rm -f realm-server-{world.Id}";
Process serverProcess = new(); Process serverProcess = new();
serverProcess.StartInfo = serverProcessInfo; serverProcess.StartInfo = serverProcessInfo;
@ -123,7 +116,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
commandProcess.Start(); commandProcess.Start();
} }
public void RunCommand(string command) public int RunCommand(string command)
{ {
ProcessStartInfo commandProcessInfo = new(); ProcessStartInfo commandProcessInfo = new();
@ -134,6 +127,9 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
commandProcess.StartInfo = commandProcessInfo; commandProcess.StartInfo = commandProcessInfo;
commandProcess.Start(); commandProcess.Start();
commandProcess.WaitForExit();
return commandProcess.ExitCode;
} }
} }
} }

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Rewrite; using Microsoft.AspNetCore.Rewrite;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Enums;
using Minecraft_Realms_Emulator.Enums; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Middlewares; using Minecraft_Realms_Emulator.Shared.Middlewares;
using Npgsql; using Npgsql;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
@ -33,6 +33,14 @@ builder.Services.AddDbContext<DataContext>(options =>
options.UseNpgsql(dataSource); options.UseNpgsql(dataSource);
}); });
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:5192");
});
});
var app = builder.Build(); var app = builder.Build();
// Initialize database // Initialize database
@ -48,10 +56,10 @@ if (app.Environment.IsDevelopment())
var scope = app.Services.CreateScope(); var scope = app.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<DataContext>(); var db = scope.ServiceProvider.GetRequiredService<DataContext>();
app.UseCors();
app.MapControllers(); app.MapControllers();
var config = new ConfigHelper(db); var mode = Environment.GetEnvironmentVariable("WORKMODE");
var mode = config.GetSetting(nameof(SettingsEnum.WorkMode));
if (mode == null) if (mode == null)
{ {
@ -59,13 +67,13 @@ if (mode == null)
Environment.Exit(1); Environment.Exit(1);
} }
if (!Enum.IsDefined(typeof(WorkModeEnum), mode.Value)) if (!Enum.IsDefined(typeof(WorkModeEnum), mode))
{ {
Console.WriteLine("Invalid server work mode, exiting"); Console.WriteLine("Invalid server work mode, exiting");
Environment.Exit(1); Environment.Exit(1);
} }
if (mode.Value == nameof(WorkModeEnum.REALMS)) if (mode == nameof(WorkModeEnum.REALMS))
{ {
var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
@ -117,7 +125,7 @@ if (mode.Value == nameof(WorkModeEnum.REALMS))
} }
} }
var rewriteOptions = new RewriteOptions().AddRewrite(@"^(?!api)(.*)$", $"modes/{mode.Value}/$1", true); var rewriteOptions = new RewriteOptions().AddRewrite(@"^(?!api)(.*)$", $"modes/{mode}/$1", true);
app.UseRewriter(rewriteOptions); app.UseRewriter(rewriteOptions);
app.UseMiddleware<MinecraftCookieMiddleware>(); app.UseMiddleware<MinecraftCookieMiddleware>();
@ -127,5 +135,5 @@ app.UseMiddleware<AdminKeyMiddleware>();
app.UseMiddleware<CheckForWorldMiddleware>(); app.UseMiddleware<CheckForWorldMiddleware>();
app.UseMiddleware<RouteLoggingMiddleware>(); app.UseMiddleware<RouteLoggingMiddleware>();
Console.WriteLine($"Running in {mode.Value} mode"); Console.WriteLine($"Running in {mode} mode");
app.Run(); app.Run();

View File

@ -3,7 +3,7 @@ FROM eclipse-temurin:21-jre-alpine
COPY . . COPY . .
RUN apk upgrade RUN apk upgrade
RUN apk add openssl RUN apk add openssl curl jq
RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz
RUN tar xzf rcon-cli.tar.gz RUN tar xzf rcon-cli.tar.gz
@ -12,7 +12,6 @@ RUN rm rcon-cli.tar.gz
RUN mv rcon-cli /bin/rcon-cli RUN mv rcon-cli /bin/rcon-cli
WORKDIR mc WORKDIR mc
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
EXPOSE 25565 EXPOSE 25565
ENTRYPOINT ["/entrypoint"] ENTRYPOINT ["/entrypoint"]

View File

@ -11,4 +11,12 @@ if [ ! -f server.properties ]; then
echo "level-name=slot-1" >> server.properties echo "level-name=slot-1" >> server.properties
fi fi
# Download latest server.jar
if [ ! -f .no-update ]; then
VERSION_URL=$(curl https://piston-meta.mojang.com/mc/game/version_manifest_v2.json | jq -r '.latest.release as $latest | .versions | to_entries[] | select(.value.id == $latest) | .value.url')
SERVER_URL=$(curl $VERSION_URL | jq -r .downloads.server.url)
wget -O server.jar $SERVER_URL
fi
java -jar server.jar java -jar server.jar

View File

@ -1,9 +0,0 @@
using Minecraft_Realms_Emulator.Entities;
namespace Minecraft_Realms_Emulator.Responses
{
public class BackupsResponse
{
public List<Backup> Backups { get; set; }
}
}

View File

@ -1,9 +0,0 @@
using Minecraft_Realms_Emulator.Requests;
namespace Minecraft_Realms_Emulator.Responses
{
public class SlotOptionsResponse : SlotOptionsRequest
{
public string Compatibility { get; set; } = null!;
}
}

View File

@ -1,8 +0,0 @@
namespace Minecraft_Realms_Emulator.Responses
{
public class SlotResponse
{
public int SlotId { get; set; }
public string Options { get; set; } = null!;
}
}

View File

@ -1,6 +1,4 @@
using Minecraft_Realms_Emulator.Entities; namespace Minecraft_Realms_Emulator.Shared.Attributes
namespace Minecraft_Realms_Emulator.Attributes
{ {
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class CheckActiveSubscription : Attribute public class CheckActiveSubscription : Attribute

View File

@ -1,6 +1,6 @@
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Attributes namespace Minecraft_Realms_Emulator.Shared.Attributes
{ {
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class CheckForWorldAttribute : Attribute public class CheckForWorldAttribute : Attribute

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Attributes namespace Minecraft_Realms_Emulator.Shared.Attributes
{ {
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class CheckRealmOwnerAttribute : Attribute public class CheckRealmOwnerAttribute : Attribute

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Attributes namespace Minecraft_Realms_Emulator.Shared.Attributes
{ {
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class RequireAdminKeyAttribute : Attribute public class RequireAdminKeyAttribute : Attribute

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Attributes namespace Minecraft_Realms_Emulator.Shared.Attributes
{ {
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class RequireMinecraftCookieAttribute : Attribute public class RequireMinecraftCookieAttribute : Attribute

View File

@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Helpers;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Helpers; using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Controllers.Admin namespace Minecraft_Realms_Emulator.Shared.Controllers.Admin
{ {
[Route("api/admin/[controller]")] [Route("api/admin/[controller]")]
[ApiController] [ApiController]

View File

@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data;
using Minecraft_Realms_Emulator.Entities;
using Minecraft_Realms_Emulator.Modes.Realms.Helpers; using Minecraft_Realms_Emulator.Modes.Realms.Helpers;
using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Controllers.Admin namespace Minecraft_Realms_Emulator.Shared.Controllers.Admin
{ {
[Route("api/admin/[controller]")] [Route("api/admin/[controller]")]
[ApiController] [ApiController]
@ -28,7 +28,8 @@ namespace Minecraft_Realms_Emulator.Controllers.Admin
[HttpGet("{wId}")] [HttpGet("{wId}")]
[CheckForWorld] [CheckForWorld]
public ActionResult<World> GetWorld(int wId) { public ActionResult<World> GetWorld(int wId)
{
var world = _context.Worlds.ToList().Find(w => w.Id == wId); var world = _context.Worlds.ToList().Find(w => w.Id == wId);
return Ok(world); return Ok(world);

View File

@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Data namespace Minecraft_Realms_Emulator.Shared.Data
{ {
public class DataContext(DbContextOptions<DataContext> options) : DbContext(options) public class DataContext(DbContextOptions<DataContext> options) : DbContext(options)
{ {

View File

@ -1,6 +1,6 @@
using System.Text.Json; using System.Text.Json;
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Backup public class Backup
{ {

View File

@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
[PrimaryKey(nameof(Key))] [PrimaryKey(nameof(Key))]
public class Configuration public class Configuration

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Connection public class Connection
{ {

View File

@ -1,9 +1,9 @@
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Invite public class Invite
{ {
public int Id { get; set; } public int Id { get; set; }
public string InvitationId { get; set; }= string.Empty; public string InvitationId { get; set; } = string.Empty;
public string RecipeintUUID { get; set; } = string.Empty; public string RecipeintUUID { get; set; } = string.Empty;
public World World { get; set; } public World World { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }

View File

@ -1,6 +1,6 @@
using System.Text.Json; using System.Text.Json;
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Notification public class Notification
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Player public class Player
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class SeenNotification public class SeenNotification
{ {

View File

@ -1,6 +1,6 @@
using Minecraft_Realms_Emulator.Requests; using Minecraft_Realms_Emulator.Shared.Requests;
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Slot : SlotOptionsRequest public class Slot : SlotOptionsRequest
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Subscription public class Subscription
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class Template public class Template
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Entities namespace Minecraft_Realms_Emulator.Shared.Entities
{ {
public class World public class World
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum CompatibilityEnum public enum CompatibilityEnum
{ {

View File

@ -1,11 +1,10 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum SettingsEnum public enum SettingsEnum
{ {
NewsLink, NewsLink,
DefaultServerAddress, DefaultServerAddress,
TrialMode, TrialMode,
WorkMode,
OnlineMode, OnlineMode,
AutomaticRealmsCreation AutomaticRealmsCreation
} }

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum StateEnum public enum StateEnum
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum SubscriptionTypeEnum public enum SubscriptionTypeEnum
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum VersionCompatibilityEnum public enum VersionCompatibilityEnum
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum WorkModeEnum public enum WorkModeEnum
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum WorldTemplateTypeEnum public enum WorldTemplateTypeEnum
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Enums namespace Minecraft_Realms_Emulator.Shared.Enums
{ {
public enum WorldTypeEnum public enum WorldTypeEnum
{ {

View File

@ -1,8 +1,8 @@
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Helpers namespace Minecraft_Realms_Emulator.Shared.Helpers
{ {
public class ConfigHelper public class ConfigHelper
{ {

View File

@ -1,13 +1,10 @@
using Minecraft_Realms_Emulator.Enums; namespace Minecraft_Realms_Emulator.Shared.Helpers.Config
namespace Minecraft_Realms_Emulator.Helpers.Config
{ {
public class Settings public class Settings
{ {
public string DefaultServerAddress { get; set; } = "127.0.0.1"; public string DefaultServerAddress { get; set; } = "127.0.0.1";
public string NewsLink { get; set; } = "https://github.com/CyberL1/Minecraft-Realms-Emulator"; public string NewsLink { get; set; } = "https://github.com/CyberL1/Minecraft-Realms-Emulator";
public bool TrialMode { get; set; } = true; public bool TrialMode { get; set; } = true;
public string WorkMode { get; set; } = nameof(WorkModeEnum.EXTERNAL);
public bool OnlineMode { get; set; } = false; public bool OnlineMode { get; set; } = false;
public bool AutomaticRealmsCreation { get; set; } = true; public bool AutomaticRealmsCreation { get; set; } = true;
} }

View File

@ -1,10 +1,10 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Helpers.Config;
using Minecraft_Realms_Emulator.Helpers.Config; using Minecraft_Realms_Emulator.Shared.Data;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Helpers namespace Minecraft_Realms_Emulator.Shared.Helpers
{ {
public class Database public class Database
{ {

View File

@ -1,9 +1,9 @@
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
namespace Minecraft_Realms_Emulator.Helpers namespace Minecraft_Realms_Emulator.Shared.Helpers
{ {
public class MinecraftServerQuery public class MinecraftServerQuery
{ {

View File

@ -1,6 +1,6 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Minecraft_Realms_Emulator.Helpers namespace Minecraft_Realms_Emulator.Shared.Helpers
{ {
public class MinecraftVersionParser public class MinecraftVersionParser
{ {

View File

@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Middlewares namespace Minecraft_Realms_Emulator.Shared.Middlewares
{ {
public class ActiveSubscriptionMiddleware(RequestDelegate next) public class ActiveSubscriptionMiddleware(RequestDelegate next)
{ {

View File

@ -1,6 +1,6 @@
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
namespace Minecraft_Realms_Emulator.Middlewares namespace Minecraft_Realms_Emulator.Shared.Middlewares
{ {
public class AdminKeyMiddleware(RequestDelegate next) public class AdminKeyMiddleware(RequestDelegate next)
{ {

View File

@ -1,9 +1,9 @@
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Responses; using Minecraft_Realms_Emulator.Shared.Responses;
namespace Minecraft_Realms_Emulator.Middlewares namespace Minecraft_Realms_Emulator.Shared.Middlewares
{ {
public class CheckForWorldMiddleware(RequestDelegate next) public class CheckForWorldMiddleware(RequestDelegate next)
{ {

View File

@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Middlewares namespace Minecraft_Realms_Emulator.Shared.Middlewares
{ {
public class CheckRealmOwnerMiddleware(RequestDelegate next) public class CheckRealmOwnerMiddleware(RequestDelegate next)
{ {

View File

@ -1,7 +1,7 @@
using Minecraft_Realms_Emulator.Attributes; using Minecraft_Realms_Emulator.Shared.Attributes;
using System.Text; using System.Text;
namespace Minecraft_Realms_Emulator.Middlewares namespace Minecraft_Realms_Emulator.Shared.Middlewares
{ {
public class MinecraftCookieMiddleware(RequestDelegate next) public class MinecraftCookieMiddleware(RequestDelegate next)
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Middlewares namespace Minecraft_Realms_Emulator.Shared.Middlewares
{ {
public class RouteLoggingMiddleware(RequestDelegate next) public class RouteLoggingMiddleware(RequestDelegate next)
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Requests namespace Minecraft_Realms_Emulator.Shared.Requests
{ {
public class PlayerRequest public class PlayerRequest
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Requests namespace Minecraft_Realms_Emulator.Shared.Requests
{ {
public class SlotOptionsRequest public class SlotOptionsRequest
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Requests namespace Minecraft_Realms_Emulator.Shared.Requests
{ {
public class WorldCreateRequest public class WorldCreateRequest
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class BackupDownloadResponse public class BackupDownloadResponse
{ {

View File

@ -0,0 +1,9 @@
using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Shared.Responses
{
public class BackupsResponse
{
public List<Backup> Backups { get; set; }
}
}

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class ErrorResponse public class ErrorResponse
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class InviteList public class InviteList
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class LivePlayerListsResponse public class LivePlayerListsResponse
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class MinecraftPlayerInfo public class MinecraftPlayerInfo
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class MinecraftServerQueryRepsonse public class MinecraftServerQueryRepsonse
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class NewsResponse public class NewsResponse
{ {

View File

@ -1,6 +1,6 @@
using Minecraft_Realms_Emulator.Entities; using Minecraft_Realms_Emulator.Shared.Entities;
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class NotificationsResponse public class NotificationsResponse
{ {

View File

@ -1,4 +1,4 @@
namespace Minecraft_Realms_Emulator.Responses namespace Minecraft_Realms_Emulator.Shared.Responses
{ {
public class OpsResponse public class OpsResponse
{ {

View File

@ -1,6 +1,4 @@
using Minecraft_Realms_Emulator.Entities; namespace Minecraft_Realms_Emulator.Shared.Responses
namespace Minecraft_Realms_Emulator.Responses
{ {
public class ServersResponse public class ServersResponse
{ {

Some files were not shown because too many files have changed in this diff Show More