Exemple #1
0
        /// <summary>
        /// Handle's whisper messages between 2 clients
        /// </summary>
        public void HandleWhisperChat(WorldSession session, ClientChatWhisper whisper)
        {
            ICharacter character = CharacterManager.Instance.GetCharacterInfo(whisper.PlayerName);

            if (character == null || !(character is Player player))
            {
                SendMessage(session, $"Player \"{whisper.PlayerName}\" not found.");
                return;
            }

            if (session.Player.Name == character.Name)
            {
                SendMessage(session, "You cannot send a message to yourself.");
                return;
            }

            bool crossFactionChat = ConfigurationManager <WorldServerConfiguration> .Instance.Config.CrossFactionChat;

            if (session.Player.Faction1 != character.Faction1 && !crossFactionChat)
            {
                SendMessage(session, $"Player \"{whisper.PlayerName}\" not found.", "", ChatChannel.System);
                return;
            }

            // echo message
            session.EnqueueMessageEncrypted(new ServerChat
            {
                Channel      = ChatChannel.Whisper,
                Name         = whisper.PlayerName,
                Text         = whisper.Message,
                Self         = true,
                CrossFaction = session.Player.Faction1 != character.Faction1,
                Formats      = ParseChatLinks(session, whisper.Formats).ToList()
            });

            // target player message
            player.Session.EnqueueMessageEncrypted(new ServerChat
            {
                Channel      = ChatChannel.Whisper,
                Name         = session.Player.Name,
                Text         = whisper.Message,
                CrossFaction = session.Player.Faction1 != character.Faction1,
                Formats      = ParseChatLinks(session, whisper.Formats).ToList(),
            });
        }
Exemple #2
0
 public static void HandleWhisper(WorldSession session, ClientChatWhisper whisper)
 {
     SocialManager.Instance.HandleWhisperChat(session, whisper);
 }