From c3f8ed3cdf4478f7eb1fc9ff75c274162caddfc0 Mon Sep 17 00:00:00 2001 From: data-bomb Date: Sun, 3 Mar 2024 13:54:29 -0800 Subject: [PATCH] Subscribe to Request Chat Event - Subscribes to the request chat event for Silence mod --- Si_ChatSilence/Si_Silence.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Si_ChatSilence/Si_Silence.cs b/Si_ChatSilence/Si_Silence.cs index 5689a75..440a7cc 100644 --- a/Si_ChatSilence/Si_Silence.cs +++ b/Si_ChatSilence/Si_Silence.cs @@ -37,7 +37,7 @@ You should have received a copy of the GNU General Public License using System.Linq; -[assembly: MelonInfo(typeof(ChatSilence), "Silence Admin Command", "1.2.0", "databomb", "https://github.com/data-bomb/Silica")] +[assembly: MelonInfo(typeof(ChatSilence), "Silence Admin Command", "1.2.1", "databomb", "https://github.com/data-bomb/Silica")] [assembly: MelonGame("Bohemia Interactive", "Silica")] [assembly: MelonOptionalDependencies("Admin Mod")] @@ -55,20 +55,16 @@ public override void OnInitializeMelon() public override void OnLateInitializeMelon() { - adminModAvailable = RegisteredMelons.Any(m => m.Info.Name == "Admin Mod"); + // register commands + HelperMethods.CommandCallback silenceCallback = Command_Silence; + HelperMethods.RegisterAdminCommand("!silence", silenceCallback, Power.Mute); - if (adminModAvailable) - { - HelperMethods.CommandCallback silenceCallback = Command_Silence; - HelperMethods.RegisterAdminCommand("!silence", silenceCallback, Power.Mute); + HelperMethods.CommandCallback unSilenceCallback = Command_UnSilence; + HelperMethods.RegisterAdminCommand("!unsilence", unSilenceCallback, Power.Mute); - HelperMethods.CommandCallback unSilenceCallback = Command_UnSilence; - HelperMethods.RegisterAdminCommand("!unsilence", unSilenceCallback, Power.Mute); - } - else - { - MelonLogger.Warning("Dependency missing: Admin Mod"); - } + + // subscribe to the OnRequestPlayerChat event + Event_Netcode.OnRequestPlayerChat += OnRequestPlayerChat; } public static void Command_Silence(Player callerPlayer, String args)