From 3ac1c1bc26c8033b328a5780cfbd44e4099f9221 Mon Sep 17 00:00:00 2001 From: "Robin C. Ladiges" Date: Wed, 22 Mar 2023 21:54:41 +0100 Subject: [PATCH] add commands: `ban enable` and `ban disable` To set the value of `BanList.Enabled` to `true` or `false` without editing the `settings.json` file. --- Server/BanLists.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Server/BanLists.cs b/Server/BanLists.cs index 9e257c7..9b9b071 100644 --- a/Server/BanLists.cs +++ b/Server/BanLists.cs @@ -13,6 +13,9 @@ public static class BanLists { get { return Settings.Instance.BanList.Enabled; } + private set { + Settings.Instance.BanList.Enabled = value; + } } private static List IPs { @@ -145,7 +148,7 @@ public static class BanLists { public static string HandleBanCommand(string[] args, MUCH much) { if (args.Length == 0) { - return "Usage: ban {player|profile|ip} ..."; + return "Usage: ban {enable|disable|player|profile|ip} ..."; } string cmd = args[0]; @@ -153,7 +156,23 @@ public static class BanLists { switch (cmd) { default: - return "Usage: ban {player|profile|ip} ..."; + return "Usage: ban {enable|disable|player|profile|ip} ..."; + + case "enable": + if (args.Length != 0) { + return "Usage: ban enable"; + } + Enabled = true; + Save(); + return "BanList enabled."; + + case "disable": + if (args.Length != 0) { + return "Usage: ban disable"; + } + Enabled = false; + Save(); + return "BanList disabled."; case "player": if (args.Length == 0) {