From 9c01f30c5e1ede6af66516c7d6fb77854cb6794a Mon Sep 17 00:00:00 2001 From: Sanae Date: Sat, 20 Aug 2022 23:31:31 -0600 Subject: [PATCH] Add the ability to disable shine sync --- Server/Program.cs | 12 +++++++++++- Server/Settings.cs | 13 +++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Server/Program.cs b/Server/Program.cs index 4fc523d..a3d3b5f 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -79,6 +79,7 @@ server.ClientJoined += (c, _) => { }; async Task ClientSyncShineBag(Client client) { + if (!Settings.Instance.Shines.Enabled) return; try { if ((bool?) client.Metadata["speedrun"] ?? false) return; ConcurrentBag clientBag = (ConcurrentBag) (client.Metadata["shineSync"] ??= new ConcurrentBag()); @@ -560,7 +561,7 @@ CommandHandler.RegisterCommand("flip", args => { }); CommandHandler.RegisterCommand("shine", args => { - const string optionUsage = "Valid options: list, clear, sync, send"; + const string optionUsage = "Valid options: list, clear, sync, send, set"; if (args.Length < 1) return optionUsage; switch (args[0]) { @@ -589,6 +590,15 @@ CommandHandler.RegisterCommand("shine", args => { } return optionUsage; + case "set" when args.Length == 2: { + if (bool.TryParse(args[1], out bool result)) { + Settings.Instance.Shines.Enabled = result; + Settings.SaveSettings(); + return result ? "Enabled shine sync" : "Disabled shine sync"; + } + + return optionUsage; + } default: return optionUsage; } diff --git a/Server/Settings.cs b/Server/Settings.cs index 048deba..307a1d5 100644 --- a/Server/Settings.cs +++ b/Server/Settings.cs @@ -45,6 +45,7 @@ public class Settings { public ScenarioTable Scenario { get; set; } = new ScenarioTable(); public BannedPlayers BanList { get; set; } = new BannedPlayers(); public DiscordTable Discord { get; set; } = new DiscordTable(); + public ShineTable Shines { get; set; } = new ShineTable(); public PersistShinesTable PersistShines { get; set; } = new PersistShinesTable(); public class ServerTable { @@ -75,9 +76,13 @@ public class Settings { public string? LogChannel { get; set; } } - public class PersistShinesTable - { - public bool Enabled { get; set; } = false; - public string Filename { get; set; } = "./moons.json"; + public class ShineTable { + public bool Enabled { get; set; } = true; + } + + public class PersistShinesTable + { + public bool Enabled { get; set; } = false; + public string Filename { get; set; } = "./moons.json"; } } \ No newline at end of file