Skip to content

Commit

Permalink
OnMessageReceivedEvent should allow modifying the input message (Than…
Browse files Browse the repository at this point in the history
…ks Venk)
  • Loading branch information
UnknownShadow200 committed Apr 10, 2021
1 parent bedbae0 commit 4b554a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions MCGalaxy/Events/PlayerEvents.cs
Expand Up @@ -165,14 +165,14 @@ public sealed class OnPlayerClickEvent : IEvent<OnPlayerClick> {
}
}

public delegate void OnMessageReceived(Player p, string message, ref bool cancel);
public delegate void OnMessageReceived(Player p, ref string message, ref bool cancel);
/// <summary> Called whenever a player recieves a message from the server or from another player. </summary>
public sealed class OnMessageRecievedEvent : IEvent<OnMessageReceived> {

public static void Call(Player p, string message, ref bool cancel) {
public static void Call(Player p, ref string message, ref bool cancel) {
IEvent<OnMessageReceived>[] items = handlers.Items;
for (int i = 0; i < items.Length; i++) {
try { items[i].method(p, message, ref cancel); }
try { items[i].method(p, ref message, ref cancel); }
catch (Exception ex) { LogHandlerException(ex, items[i]); }
}
}
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Network/Player.Networking.cs
Expand Up @@ -179,7 +179,7 @@ public partial class Player : IDisposable, INetProtocol {
message = Chat.Format(message, this);

bool cancel = false;
OnMessageRecievedEvent.Call(this, message, ref cancel);
OnMessageRecievedEvent.Call(this, ref message, ref cancel);
if (cancel) return;

try {
Expand Down

0 comments on commit 4b554a9

Please sign in to comment.