From a573ca17974951b11cb4e341f573da620d9e56e5 Mon Sep 17 00:00:00 2001 From: Bishbash777 <50243964+Bishbash777@users.noreply.github.com> Date: Wed, 17 Mar 2021 12:10:49 +0000 Subject: [PATCH] Only patch if ranks are enabled (#183) Co-authored-by: Bishbash777 --- Essentials/Patches/ChatMessagePatch.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Essentials/Patches/ChatMessagePatch.cs b/Essentials/Patches/ChatMessagePatch.cs index 2f062e6..07135c4 100644 --- a/Essentials/Patches/ChatMessagePatch.cs +++ b/Essentials/Patches/ChatMessagePatch.cs @@ -34,11 +34,13 @@ public static MethodInfo FindOverLoadMethod( MethodInfo[] methodInfo,string name } public static void Patch(PatchContext ctx) { - var target = FindOverLoadMethod(typeof(MyMultiplayerBase).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static), "OnChatMessageReceived_Server", 1); - var patchMethod = typeof(ChatMessagePatch).GetMethod(nameof(OnChatMessageReceived_Server), BindingFlags.Static | BindingFlags.NonPublic); - ctx.GetPattern(target).Prefixes.Add(patchMethod); + if (EssentialsPlugin.Instance.Config.EnableRanks) { + var target = FindOverLoadMethod(typeof(MyMultiplayerBase).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static), "OnChatMessageReceived_Server", 1); + var patchMethod = typeof(ChatMessagePatch).GetMethod(nameof(OnChatMessageReceived_Server), BindingFlags.Static | BindingFlags.NonPublic); + ctx.GetPattern(target).Prefixes.Add(patchMethod); - Log.Info("Patched OnChatMessageReceived_Server!"); + Log.Info("Patched OnChatMessageReceived_Server!"); + } } private static bool OnChatMessageReceived_Server(ref ChatMsg msg) {