0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-22 03:05:16 +00:00

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) { async Task ClientSyncShineBag(Client client) {
if (!Settings.Instance.Shines.Enabled) return;
try { try {
if ((bool?) client.Metadata["speedrun"] ?? false) return; if ((bool?) client.Metadata["speedrun"] ?? false) return;
ConcurrentBag<int> clientBag = (ConcurrentBag<int>) (client.Metadata["shineSync"] ??= new ConcurrentBag<int>()); ConcurrentBag<int> clientBag = (ConcurrentBag<int>) (client.Metadata["shineSync"] ??= new ConcurrentBag<int>());
@ -560,7 +561,7 @@ CommandHandler.RegisterCommand("flip", args => {
}); });
CommandHandler.RegisterCommand("shine", 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) if (args.Length < 1)
return optionUsage; return optionUsage;
switch (args[0]) { switch (args[0]) {
@ -589,6 +590,15 @@ CommandHandler.RegisterCommand("shine", args => {
} }
return optionUsage; 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: default:
return optionUsage; return optionUsage;
} }

View file

@ -45,6 +45,7 @@ public class Settings {
public ScenarioTable Scenario { get; set; } = new ScenarioTable(); public ScenarioTable Scenario { get; set; } = new ScenarioTable();
public BannedPlayers BanList { get; set; } = new BannedPlayers(); public BannedPlayers BanList { get; set; } = new BannedPlayers();
public DiscordTable Discord { get; set; } = new DiscordTable(); public DiscordTable Discord { get; set; } = new DiscordTable();
public ShineTable Shines { get; set; } = new ShineTable();
public PersistShinesTable PersistShines { get; set; } = new PersistShinesTable(); public PersistShinesTable PersistShines { get; set; } = new PersistShinesTable();
public class ServerTable { public class ServerTable {
@ -75,9 +76,13 @@ public class Settings {
public string? LogChannel { get; set; } public string? LogChannel { get; set; }
} }
public class PersistShinesTable public class ShineTable {
{ public bool Enabled { get; set; } = true;
public bool Enabled { get; set; } = false; }
public string Filename { get; set; } = "./moons.json";
public class PersistShinesTable
{
public bool Enabled { get; set; } = false;
public string Filename { get; set; } = "./moons.json";
} }
} }