|
1 | | -using BrokeProtocol.API; |
2 | | -using BrokeProtocol.Entities; |
3 | | -using BrokeProtocol.Utility; |
4 | | -using System; |
5 | | -using BPEssentials.ExtensionMethods; |
6 | | -using BrokeProtocol.Utility.Networking; |
7 | | -using BPEssentials.Utils; |
8 | | - |
9 | | -namespace BPEssentials.ChatHandlers |
10 | | -{ |
11 | | - public class LocalChat : IScript |
12 | | - { |
13 | | - [Target(GameSourceEvent.PlayerLocalChatMessage, ExecutionMode.Override)] |
14 | | - public void OnEvent(ShPlayer player, string message) |
15 | | - { |
16 | | - if (player.manager.svManager.chatted.Limit(player)) |
17 | | - { |
18 | | - return; |
19 | | - } |
20 | | - |
21 | | - Core.Instance.Logger.LogInfo($"[LOCAL] {player.username.CleanerMessage()}: {message.CleanerMessage()}"); |
22 | | - |
23 | | - |
24 | | - if (CommandHandler.OnEvent(player, message)) // 'true' if message starts with command prefix |
25 | | - { |
26 | | - return; |
27 | | - } |
28 | | - |
29 | | - if (Core.Instance.Settings.General.LocalChatOverHead) |
30 | | - { |
31 | | - player.svPlayer.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.LocalChatMessage, player.ID, message.CleanerMessage()); |
32 | | - } |
33 | | - if (Core.Instance.Settings.General.LocalChatInChat) |
34 | | - { |
35 | | - player.svPlayer.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.GameMessage, ChatUtils.FormatMessage(player, message, "localformat")); |
36 | | - } |
37 | | - } |
38 | | - } |
39 | | -} |
| 1 | +using BPEssentials.ExtensionMethods; |
| 2 | +using BPEssentials.Utils; |
| 3 | +using BrokeProtocol.API; |
| 4 | +using BrokeProtocol.Collections; |
| 5 | +using BrokeProtocol.Entities; |
| 6 | +using BrokeProtocol.Utility.Networking; |
| 7 | + |
| 8 | +namespace BPEssentials.ChatHandlers |
| 9 | +{ |
| 10 | + public class LocalChat : IScript |
| 11 | + { |
| 12 | + private static LimitQueue<ShPlayer> chatted = new LimitQueue<ShPlayer>(8, 20f); |
| 13 | + |
| 14 | + [Target(GameSourceEvent.PlayerLocalChatMessage, ExecutionMode.Override)] |
| 15 | + public void OnEvent(ShPlayer player, string message) |
| 16 | + { |
| 17 | + if (chatted.Limit(player)) |
| 18 | + { |
| 19 | + return; |
| 20 | + } |
| 21 | + |
| 22 | + Core.Instance.Logger.LogInfo($"[LOCAL] {player.username.CleanerMessage()}: {message.CleanerMessage()}"); |
| 23 | + |
| 24 | + |
| 25 | + if (CommandHandler.OnEvent(player, message)) // 'true' if message starts with command prefix |
| 26 | + { |
| 27 | + return; |
| 28 | + } |
| 29 | + |
| 30 | + if (Core.Instance.Settings.General.LocalChatOverHead) |
| 31 | + { |
| 32 | + player.svPlayer.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.LocalChatMessage, player.ID, message.CleanerMessage()); |
| 33 | + } |
| 34 | + if (Core.Instance.Settings.General.LocalChatInChat) |
| 35 | + { |
| 36 | + player.svPlayer.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.GameMessage, ChatUtils.FormatMessage(player, message, "localformat")); |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | +} |
0 commit comments