fix: world slots

This commit is contained in:
CyberL1 2024-12-13 21:16:34 +01:00
parent 54a05537c4
commit 4605ac5fef
5 changed files with 60 additions and 49 deletions

View File

@ -7,6 +7,7 @@ using Minecraft_Realms_Emulator.Shared.Data;
using Minecraft_Realms_Emulator.Shared.Entities;
using Minecraft_Realms_Emulator.Shared.Requests;
using Minecraft_Realms_Emulator.Shared.Responses;
using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Modes.External
{
@ -73,7 +74,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -116,7 +117,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -177,7 +178,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -233,7 +234,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -333,7 +334,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -378,7 +379,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -443,26 +444,26 @@ namespace Minecraft_Realms_Emulator.Modes.External
slots.Add(new SlotResponse()
{
SlotId = slot.SlotId,
Options =
Options = JsonConvert.SerializeObject(new
{
SlotName = slot.SlotName,
GameMode = slot.GameMode,
Hardcore = slot.GameMode == 3,
Difficulty = slot.Difficulty,
SpawnProtection = slot.SpawnProtection,
ForceGameMode = slot.ForceGameMode,
Pvp = slot.Pvp,
SpawnAnimals = slot.SpawnAnimals,
SpawnMonsters = slot.SpawnMonsters,
SpawnNPCs = slot.SpawnNPCs,
CommandBlocks = slot.CommandBlocks,
Version = slot.Version,
Compatibility = compatibility
}
slotName = slot.SlotName,
gameMode = slot.GameMode,
hardcore = slot.Difficulty == 3,
difficulty = slot.Difficulty,
spawnProection = slot.SpawnProtection,
forceGameMode = slot.ForceGameMode,
pvp = slot.Pvp,
spawnAnimals = slot.SpawnAnimals,
spawnMonsters = slot.SpawnMonsters,
spawnNPCs = slot.SpawnNPCs,
commandBlocks = slot.CommandBlocks,
version = slot.Version,
compatibility
})
});
}
SlotOptionsResponse activeSlotOptions = slots.Find(s => s.SlotId == activeSlot.SlotId).Options;
var activeSlotOptions = JsonConvert.DeserializeObject<SlotOptionsResponse>(slots.Find(s => s.SlotId == activeSlot.SlotId).Options);
if (world.ParentWorld != null)
{
@ -477,7 +478,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.GameMode == 3,
IsHardcore = activeSlot.GameMode == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,

View File

@ -10,6 +10,7 @@ using Minecraft_Realms_Emulator.Shared.Requests;
using Minecraft_Realms_Emulator.Shared.Responses;
using System.Net;
using System.Net.Sockets;
using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
{
@ -76,7 +77,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -119,7 +120,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -180,7 +181,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -236,7 +237,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -336,7 +337,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -381,7 +382,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,
@ -446,26 +447,26 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
slots.Add(new SlotResponse()
{
SlotId = slot.SlotId,
Options =
Options = JsonConvert.SerializeObject(new
{
SlotName = slot.SlotName,
GameMode = slot.GameMode,
Hardcore = slot.Difficulty == 3,
Difficulty = slot.Difficulty,
SpawnProtection = slot.SpawnProtection,
ForceGameMode = slot.ForceGameMode,
Pvp = slot.Pvp,
SpawnAnimals = slot.SpawnAnimals,
SpawnMonsters = slot.SpawnMonsters,
SpawnNPCs = slot.SpawnNPCs,
CommandBlocks = slot.CommandBlocks,
Version = slot.Version,
Compatibility = compatibility
}
slotName = slot.SlotName,
gameMode = slot.GameMode,
hardcore = slot.Difficulty == 3,
difficulty = slot.Difficulty,
spawnProection = slot.SpawnProtection,
forceGameMode = slot.ForceGameMode,
pvp = slot.Pvp,
spawnAnimals = slot.SpawnAnimals,
spawnMonsters = slot.SpawnMonsters,
spawnNPCs = slot.SpawnNPCs,
commandBlocks = slot.CommandBlocks,
version = slot.Version,
compatibility
})
});
}
SlotOptionsResponse activeSlotOptions = slots.Find(s => s.SlotId == activeSlot.SlotId).Options;
var activeSlotOptions = JsonConvert.DeserializeObject<SlotOptionsResponse>(slots.Find(s => s.SlotId == activeSlot.SlotId).Options);
if (world.ParentWorld != null)
{
@ -480,7 +481,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
Name = world.Name,
Motd = world.Motd,
GameMode = activeSlot.GameMode,
Hardcore = activeSlot.Difficulty == 3,
IsHardcore = activeSlot.Difficulty == 3,
State = world.State,
WorldType = world.WorldType,
MaxPlayers = world.MaxPlayers,

View File

@ -3,11 +3,12 @@
public class SlotResponse
{
public int SlotId { get; set; }
public SlotOptionsResponse Options { get; set; } = null!;
public SlotSettingsResponse Settings { get; set; } = null!;
public string Options { get; set; } = null!;
public SlotResponse()
{
Options = new SlotOptionsResponse();
Settings = new SlotSettingsResponse();
}
}
}

View File

@ -0,0 +1,7 @@
namespace Minecraft_Realms_Emulator.Shared.Responses
{
public class SlotSettingsResponse
{
public bool Hardcore { get; set; }
}
}

View File

@ -5,11 +5,12 @@ namespace Minecraft_Realms_Emulator.Shared.Responses
public class WorldResponse : World
{
public string RemoteSubscriptionId { get; set; } = new Guid().ToString();
public bool Hardcore { get; set; }
public bool IsHardcore { get; set; } = false;
public int GameMode { get; set; }
public int DaysLeft { get; set; } = 30;
public bool Expired { get; set; } = false;
public bool ExpiredTrial { get; set; } = false;
public bool GracePeriod { get; set; } = false;
public string Compatibility { get; set; } = null!;
public List<SlotResponse> Slots { get; set; } = null!;
public string ActiveVersion { get; set; } = null!;