Skip to content

Commit

Permalink
Only patch if ranks are enabled (#183)
Browse files Browse the repository at this point in the history
Co-authored-by: Bishbash777 <[email protected]>
  • Loading branch information
Bishbash777 and Bishbash777 authored Mar 17, 2021
1 parent 531c31d commit a573ca1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Essentials/Patches/ChatMessagePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a573ca1

Please sign in to comment.