Skip to content

Commit b19b8d9

Browse files
Bishbash777Bishbash777
andauthored
Quick fixes (#185)
* Only patch if ranks are enabled * fix dumb * Add catch for patch * bring back motd Co-authored-by: Bishbash777 <[email protected]>
1 parent 9f5ae7d commit b19b8d9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Essentials/EssentialsConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public EssentialsConfig()
3434
public ObservableCollection<InfoCommand> InfoCommands { get; } = new ObservableCollection<InfoCommand>();
3535

3636
private string _motd;
37+
[Display(Name = "Motd", Description = "Message displayed to players upon connection")]
3738
public string Motd { get => _motd; set => SetValue(ref _motd, value); }
3839

3940
public bool _enableRanks = false;

Essentials/Patches/ChatMessagePatch.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ public static MethodInfo FindOverLoadMethod( MethodInfo[] methodInfo,string name
3434
}
3535

3636
public static void Patch(PatchContext ctx) {
37-
if (EssentialsPlugin.Instance.Config.EnableRanks) {
37+
try {
3838
var target = FindOverLoadMethod(typeof(MyMultiplayerBase).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static), "OnChatMessageReceived_Server", 1);
3939
var patchMethod = typeof(ChatMessagePatch).GetMethod(nameof(OnChatMessageReceived_Server), BindingFlags.Static | BindingFlags.NonPublic);
4040
ctx.GetPattern(target).Prefixes.Add(patchMethod);
4141

4242
Log.Info("Patched OnChatMessageReceived_Server!");
4343
}
44+
catch {
45+
Log.Error("Failed to patch!");
46+
}
4447
}
4548

4649
private static bool OnChatMessageReceived_Server(ref ChatMsg msg) {

0 commit comments

Comments
 (0)