0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-25 04:35:18 +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,6 +76,10 @@ public class Settings {
public string? LogChannel { get; set; } public string? LogChannel { get; set; }
} }
public class ShineTable {
public bool Enabled { get; set; } = true;
}
public class PersistShinesTable public class PersistShinesTable
{ {
public bool Enabled { get; set; } = false; public bool Enabled { get; set; } = false;