mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2024-12-22 04:18:21 -05:00
refactor: move WorkMode setting to environment variable
This commit is contained in:
parent
f1a5ddd98c
commit
84548585ac
@ -50,8 +50,7 @@ var db = scope.ServiceProvider.GetRequiredService<DataContext>();
|
|||||||
|
|
||||||
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 +58,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 +116,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 +126,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();
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
NewsLink,
|
NewsLink,
|
||||||
DefaultServerAddress,
|
DefaultServerAddress,
|
||||||
TrialMode,
|
TrialMode,
|
||||||
WorkMode,
|
|
||||||
OnlineMode,
|
OnlineMode,
|
||||||
AutomaticRealmsCreation
|
AutomaticRealmsCreation
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
using Minecraft_Realms_Emulator.Shared.Enums;
|
namespace Minecraft_Realms_Emulator.Shared.Helpers.Config
|
||||||
|
|
||||||
namespace Minecraft_Realms_Emulator.Shared.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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user