mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-11-23 22:58:21 -05:00
feat: more settings (OnlineMode, AutomaticRealmsCreation)
This commit is contained in:
parent
f9f07756ac
commit
11444c75b1
@ -5,6 +5,8 @@
|
|||||||
NewsLink,
|
NewsLink,
|
||||||
DefaultServerAddress,
|
DefaultServerAddress,
|
||||||
TrialMode,
|
TrialMode,
|
||||||
WorkMode
|
WorkMode,
|
||||||
|
OnlineMode,
|
||||||
|
AutomaticRealmsCreation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,7 @@ namespace Minecraft_Realms_Emulator.Helpers.Config
|
|||||||
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 string WorkMode { get; set; } = nameof(WorkModeEnum.EXTERNAL);
|
||||||
|
public bool OnlineMode { get; set; } = false;
|
||||||
|
public bool AutomaticRealmsCreation { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,23 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("available")]
|
[HttpGet("available")]
|
||||||
public ActionResult<bool> GetAvailable()
|
public async Task<ActionResult<bool>> GetAvailable()
|
||||||
{
|
{
|
||||||
|
if (new ConfigHelper(_context).GetSetting(nameof(SettingsEnum.OnlineMode)).Value)
|
||||||
|
{
|
||||||
|
string cookie = Request.Headers.Cookie;
|
||||||
|
string playerUUID = cookie.Split(";")[0].Split(":")[2];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await new HttpClient().GetFromJsonAsync<MinecraftPlayerInfo>($"https://sessionserver.mojang.com/session/minecraft/profile/{playerUUID}");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace Minecraft_Realms_Emulator.Modes.External
|
|||||||
|
|
||||||
List<WorldResponse> allWorlds = [];
|
List<WorldResponse> allWorlds = [];
|
||||||
|
|
||||||
if (ownedWorlds.ToArray().Length == 0)
|
if (ownedWorlds.ToArray().Length == 0 && new ConfigHelper(_context).GetSetting(nameof(SettingsEnum.AutomaticRealmsCreation)).Value)
|
||||||
{
|
{
|
||||||
var world = new World
|
var world = new World
|
||||||
{
|
{
|
||||||
|
@ -20,8 +20,23 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("available")]
|
[HttpGet("available")]
|
||||||
public ActionResult<bool> GetAvailable()
|
public async Task<ActionResult<bool>> GetAvailable()
|
||||||
{
|
{
|
||||||
|
if (new ConfigHelper(_context).GetSetting(nameof(SettingsEnum.OnlineMode)).Value)
|
||||||
|
{
|
||||||
|
string cookie = Request.Headers.Cookie;
|
||||||
|
string playerUUID = cookie.Split(";")[0].Split(":")[2];
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await new HttpClient().GetFromJsonAsync<MinecraftPlayerInfo>($"https://sessionserver.mojang.com/session/minecraft/profile/{playerUUID}");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
|||||||
|
|
||||||
List<WorldResponse> allWorlds = [];
|
List<WorldResponse> allWorlds = [];
|
||||||
|
|
||||||
if (ownedWorlds.ToArray().Length == 0)
|
if (ownedWorlds.ToArray().Length == 0 && new ConfigHelper(_context).GetSetting(nameof(SettingsEnum.AutomaticRealmsCreation)).Value)
|
||||||
{
|
{
|
||||||
var world = new World
|
var world = new World
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user