diff --git a/Server/Program.cs b/Server/Program.cs index 6b2064d..d27582d 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -74,7 +74,7 @@ async Task ClientSyncShineBag(Client client) { try { if ((bool?) client.Metadata["disableShineSync"] ?? false) return; ConcurrentBag clientBag = (ConcurrentBag) (client.Metadata["shineSync"] ??= new ConcurrentBag()); - foreach (int shine in shineBag.Except(clientBag).ToArray()) { + foreach (int shine in shineBag.Except(clientBag).Except(Settings.Instance.Shines.Excluded).ToArray()) { if (!client.Connected) return; await client.Send(new ShinePacket { ShineId = shine @@ -203,6 +203,10 @@ void logError(Task x) { case ShinePacket shinePacket: { if (!Settings.Instance.Shines.Enabled) return false; + if (Settings.Instance.Shines.Excluded.Contains(shinePacket.ShineId)) { + c.Logger.Info($"Got moon {shinePacket.ShineId} (excluded)"); + return false; + } if (c.Metadata["loadedSave"] is false) break; ConcurrentBag playerBag = (ConcurrentBag)c.Metadata["shineSync"]!; shineBag.Add(shinePacket.ShineId); @@ -565,12 +569,16 @@ await server.Broadcast(new TagPacket { }); CommandHandler.RegisterCommand("shine", args => { - const string optionUsage = "Valid options: list, clear, sync, send, set"; + const string optionUsage = "Valid options: list, clear, sync, send, set, include, exclude"; if (args.Length < 1) return optionUsage; switch (args[0]) { case "list" when args.Length == 1: - return $"Shines: {string.Join(", ", shineBag)}"; + return $"Shines: {string.Join(", ", shineBag)}" + ( + Settings.Instance.Shines.Excluded.Count() > 0 + ? "\nExcluded Shines: " + string.Join(", ", Settings.Instance.Shines.Excluded) + : "" + ); case "clear" when args.Length == 1: shineBag.Clear(); Task.Run(PersistShines); @@ -605,6 +613,21 @@ await c.Send(new ShinePacket { return optionUsage; } + case "exclude" when args.Length == 2: + case "include" when args.Length == 2: { + if (int.TryParse(args[1], out int sid)) { + if (args[0] == "exclude") { + Settings.Instance.Shines.Excluded.Add(sid); + Settings.SaveSettings(); + return $"Exclude shine {sid} from syncing."; + } else { + Settings.Instance.Shines.Excluded.Remove(sid); + Settings.SaveSettings(); + return $"No longer exclude shine {sid} from syncing."; + } + } + return optionUsage; + } default: return optionUsage; } diff --git a/Server/Settings.cs b/Server/Settings.cs index 977b3e8..ab28286 100644 --- a/Server/Settings.cs +++ b/Server/Settings.cs @@ -81,6 +81,7 @@ public class DiscordTable { public class ShineTable { public bool Enabled { get; set; } = true; + public ISet Excluded { get; set; } = new SortedSet { 496 }; public bool ClearOnNewSaves { get; set; } = false; }