readd OnSendingMotd event

This commit is contained in:
UnknownShadow200 2019-01-18 22:49:34 +11:00
parent c1b881678c
commit 6f05dd57ee
2 changed files with 16 additions and 0 deletions

View File

@ -222,6 +222,21 @@ namespace MCGalaxy.Events.PlayerEvents {
catch (Exception ex) { LogHandlerException(ex, items[i]); }
}
}
}
public delegate void OnSendingMotd(Player p, ref string motd);
/// <summary> Called when MOTD is being sent to a player. </summary>
/// <remarks> To change MOTD for a player in general (e.g. for /fly), use OnGettingMotdEvent instead. </remarks>
public sealed class OnSendingMotdEvent : IEvent<OnSendingMotd> {
public static void Call(Player p, ref string motd) {
IEvent<OnSendingMotd>[] items = handlers.Items;
// Can't use CallCommon because we need to pass arguments by ref
for (int i = 0; i < items.Length; i++) {
try { items[i].method(p, ref motd); }
catch (Exception ex) { LogHandlerException(ex, items[i]); }
}
}
}
public delegate void OnPlayerSpawning(Player p, ref Position pos, ref byte yaw, ref byte pitch, bool respawning);

View File

@ -152,6 +152,7 @@ namespace MCGalaxy {
public void SendMapMotd() {
string motd = GetMotd();
motd = Chat.Format(motd, this);
OnSendingMotdEvent.Call(this, ref motd);
byte[] packet = Packet.Motd(this, motd);
Send(packet);