From 62355c7e4ffabfed0945e94893dbb978348d8473 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 15 Dec 2022 23:00:51 +1100 Subject: [PATCH] Add API for unregistering multiple commands --- MCGalaxy/Commands/Command.cs | 4 ++++ MCGalaxy/Commands/Information/CmdCommands.cs | 3 ++- MCGalaxy/Modules/Moderation/Notes/NotesPlugin.cs | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MCGalaxy/Commands/Command.cs b/MCGalaxy/Commands/Command.cs index 207c9e1e0..e95bba91f 100644 --- a/MCGalaxy/Commands/Command.cs +++ b/MCGalaxy/Commands/Command.cs @@ -123,6 +123,10 @@ public abstract partial class Command return removed; } + public static void Unregister(params Command[] cmds) { + foreach (Command cmd in cmds) { Unregister(cmd); } + } + public static string GetColoredName(Command cmd) { LevelPermission perm = CommandPerms.MinPerm(cmd); diff --git a/MCGalaxy/Commands/Information/CmdCommands.cs b/MCGalaxy/Commands/Information/CmdCommands.cs index 0131f8429..1b76523bc 100644 --- a/MCGalaxy/Commands/Information/CmdCommands.cs +++ b/MCGalaxy/Commands/Information/CmdCommands.cs @@ -79,7 +79,8 @@ public sealed class CmdCommands : Command2 static void PrintRankCommands(Player p, string sort, string modifier, Group group, bool own) { List cmds = new List(); - foreach (Command c in Command.allCmds) { + foreach (Command c in Command.allCmds) + { string disabled = Command.GetDisabledReason(c.Enabled); if (disabled == null && group.Commands.Contains(c)) cmds.Add(c); } diff --git a/MCGalaxy/Modules/Moderation/Notes/NotesPlugin.cs b/MCGalaxy/Modules/Moderation/Notes/NotesPlugin.cs index 9e5339393..8650c5686 100644 --- a/MCGalaxy/Modules/Moderation/Notes/NotesPlugin.cs +++ b/MCGalaxy/Modules/Moderation/Notes/NotesPlugin.cs @@ -36,8 +36,7 @@ public sealed class NotesPlugin : Plugin public override void Unload(bool shutdown) { OnModActionEvent.Unregister(HandleModerationAction); - Command.Unregister(notesCmd); - Command.Unregister(myNotesCmd); + Command.Unregister(notesCmd, myNotesCmd); }