Add the ability to disable shine sync

This commit is contained in:
Sanae 2022-08-20 23:31:31 -06:00
parent cee8bd580f
commit 9c01f30c5e
2 changed files with 20 additions and 5 deletions

View File

@ -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<int> clientBag = (ConcurrentBag<int>) (client.Metadata["shineSync"] ??= new ConcurrentBag<int>());
@ -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;
}

View File

@ -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";
}
}