Skip to content

Commit

Permalink
Merge pull request #66 from AnauNaga/toggle-custom-scenarios-command
Browse files Browse the repository at this point in the history
custom scenarios are now toggleable through a command
  • Loading branch information
Byte-Nova authored Apr 22, 2024
2 parents 265f0fb + 3b264e9 commit aa80f8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/Server/Core/Master.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ private static void LoadServerValues()
Logger.WriteToConsole("Loaded server values", Logger.LogMode.Warning);
}

public static void SaveServerValues(ServerValuesFile serverValues)
{
string path = Path.Combine(corePath, "ServerValues.json");

Serializer.SerializeToFile(path, serverValues);

Logger.WriteToConsole("Saved server values", Logger.LogMode.Warning);
}

private static void LoadEventValues()
{
string path = Path.Combine(corePath, "EventValues.json");
Expand Down
11 changes: 11 additions & 0 deletions Source/Server/Managers/ServerCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public static class ServerCommandStorage
"Disables custom difficulty in the server",
DisableDifficultyCommandAction);

private static ServerCommand toggleCustomScenariosCommand = new ServerCommand("togglecustomscenarios", 0,
"enables/disables custom scenarios on the server",
ToggleCustomScenariosCommandAction);

private static ServerCommand quitCommand = new ServerCommand("quit", 0,
"Saves all player data and then closes the server",
QuitCommandAction);
Expand Down Expand Up @@ -216,6 +220,7 @@ public static class ServerCommandStorage
deletePlayerCommand,
enableDifficultyCommand,
disableDifficultyCommand,
toggleCustomScenariosCommand,
quitCommand,
forceQuitCommand
};
Expand Down Expand Up @@ -686,6 +691,12 @@ private static void DisableDifficultyCommandAction()
}
}

private static void ToggleCustomScenariosCommandAction()
{
Master.serverValues.AllowCustomScenarios = !Master.serverValues.AllowCustomScenarios;
Logger.WriteToConsole($"Custom scenarios are now {(Master.serverValues.AllowCustomScenarios ? ("Enabled") : ("Disabled"))}", Logger.LogMode.Warning);
Master.SaveServerValues(Master.serverValues);
}
private static void QuitCommandAction()
{
Master.isClosing = true;
Expand Down

0 comments on commit aa80f8c

Please sign in to comment.