mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-21 18:55:17 +00:00
Add the ability to disable shine sync
This commit is contained in:
parent
cee8bd580f
commit
9c01f30c5e
2 changed files with 20 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue