public void RegisterClient(WorldClient Client, ChatChannelEnum ChannelType) { if (this.myChannels.ContainsKey(ChannelType)) { Client.RegisterChatChannel(this.myChannels[ChannelType]); } }
public ChatChannelMessage(ChatChannelEnum Channel, long ActorId, string ActorName, string Message) { this.Channel = Channel; this.ActorId = ActorId; this.ActorName = ActorName; this.Message = Message; }
public void UnRegisterChatChannel(ChatChannelEnum Channel) { lock (this.myChatChannels) { if (this.myChatChannels.ContainsKey(Channel) && this.myChatChannels[Channel] != null) { this.UnRegisterWorldEvent(this.myChatChannels[Channel]); this.myChatChannels[Channel] = null; } } }
public void EnableChatChannel(ChatChannelEnum Channel) { if (!this.myChatChannelEnabled.Contains(Channel)) { this.myChatChannelEnabled.Add(Channel); } if (!this.EnabledChannels.Contains((char)Channel)) { this.EnabledChannels += (char)Channel; } }
public void DisableChatChannel(ChatChannelEnum Channel) { if (this.myChatChannelEnabled.Contains(Channel)) { this.myChatChannelEnabled.Remove(Channel); } if (this.EnabledChannels.Contains((char)Channel)) { this.EnabledChannels = EnabledChannels.Remove(EnabledChannels.IndexOf((char)Channel), 1); } }
public void RaiseChatMessage(ChatChannelEnum Channel, string Content) { if (!this.Character.IsChatChannelEnable(Channel)) { return; } if (this.myChatChannels.ContainsKey(Channel)) { if (this.myChatChannels[Channel] != null && WorldServer.GetChatController().canSendMessage(this, Channel)) { if (ChatTiming.Exist(Channel)) { this.myChatRestrictions[Channel] = Program.currentTimeMillis(); } if (Content != String.Empty && Content[0] == '.' && this.myFight == null) { var parameters = new CommandParameters(Content.Substring(1), false); var command = JSKernel.CommandsPlayer.Get(parameters.Prefix); if (command != null) { bool result = command.callAction(this, parameters); if (!result) { Send(new ChatGameMessage("Commande invalide , tapez .help pour plus d'infos", "FF0000")); return; } return; } else { Send(new ChatGameMessage("Commande invalide , tapez .help pour plus d'infos", "FF0000")); return; } /*TeraScript Script = ScriptKernel.getScript(Content.Substring(1).Split(' ')[0].ToLower()); * if (Script != null) * { * Script.apply(this.Character); * return; * } * else * { * Send(new ChatGameMessage("Commande invalide , tapez .help pour plus d'infos", "FF0000")); * return; * }*/ } } } }
/// <summary> /// /// </summary> /// <param name="channel"></param> /// <param name="message"></param> /// <param name="whispedCharacter"></param> public virtual bool DispatchChatMessage(ChatChannelEnum channel, string message, CharacterEntity whispedCharacter = null) { var channelData = m_chatByChannel[channel]; if (channelData == null) { return(false); } if (channel != ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE) { if (message.Equals(channelData.LastMessage, StringComparison.OrdinalIgnoreCase)) { Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_CHAT_SAME_MESSAGE)); return(false); } channelData.LastMessage = message; if (UpdateTime < channelData.NextTime) { Dispatch(WorldMessage.IM_INFO_MESSAGE(InformationEnum.INFO_CHAT_SPAM_RESTRICTED, Math.Ceiling((channelData.NextTime - UpdateTime) * 0.001))); return(false); } var delay = WorldConfig.CHAT_RESTRICTED_DELAY.ContainsKey(channel) ? WorldConfig.CHAT_RESTRICTED_DELAY[channel] : 0; channelData.NextTime = UpdateTime + delay; } var dispatcher = channelData.Dispatcher(); if (dispatcher != null) { switch (channel) { case ChatChannelEnum.CHANNEL_PRIVATE_SEND: case ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE: dispatcher(WorldMessage.CHAT_MESSAGE(channel, whispedCharacter.Id, whispedCharacter.Name, message)); break; default: dispatcher(WorldMessage.CHAT_MESSAGE(channel, Id, Name, message)); break; } } return(true); }
public ChatChannel(ChatChannelEnum ChannelType) { this.myChannelType = ChannelType; }
/// <summary> /// /// </summary> /// <param name="channelType"></param> /// <param name="channel"></param> public void SetChatChannel(ChatChannelEnum channelType, Func <Action <string> > channel) { m_chatByChannel[channelType].Dispatcher = channel; }
public bool IsChatChannelEnable(ChatChannelEnum Channel) { return(this.myChatChannelEnabled.Contains(Channel)); }
/// <summary> /// /// </summary> /// <param name="channelType"></param> /// <param name="channel"></param> public void SetChatChannel(ChatChannelEnum channelType, Func<Action<string>> channel) { m_chatByChannel[channelType].Dispatcher = channel; }
public static int getTime(ChatChannelEnum Channel) { return(myChatRestrictions[Channel]); }
public static bool Exist(ChatChannelEnum Channel) { return(myChatRestrictions.ContainsKey(Channel)); }
public Boolean canSendMessage(WorldClient Client, ChatChannelEnum ChannelType) { ; switch (ChannelType) { case ChatChannelEnum.CHANNEL_ALIGNMENT: if (Client.Character.Deshonor >= 1) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 83, getTimeEplased(Client, ChannelType).ToString())); return(false); } if (Client.Character.Alignement == 0) { Client.Send(new BasicNoOperationMessage()); return(false); } else if (getTimeLeft(Client, ChannelType) < ChatTiming.getTime(ChannelType)) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.INFO, 115, getTimeEplased(Client, ChannelType).ToString())); return(false); } break; case ChatChannelEnum.CHANNEL_GENERAL: if (getTimeLeft(Client, ChannelType) < ChatTiming.getTime(ChannelType)) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.UNK, 184)); return(false); } break; case ChatChannelEnum.CHANNEL_GUILD: if (getTimeLeft(Client, ChannelType) < ChatTiming.getTime(ChannelType)) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.UNK, 184)); return(false); } break; case ChatChannelEnum.CHANNEL_GROUP: if (getTimeLeft(Client, ChannelType) < ChatTiming.getTime(ChannelType)) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.UNK, 184)); return(false); } break; case ChatChannelEnum.CHANNEL_RECRUITMENT: if (getTimeLeft(Client, ChannelType) < ChatTiming.getTime(ChannelType)) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.INFO, 115, getTimeEplased(Client, ChannelType).ToString())); return(false); } break; case ChatChannelEnum.CHANNEL_DEALING: if (getTimeLeft(Client, ChannelType) < ChatTiming.getTime(ChannelType)) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.INFO, 115, getTimeEplased(Client, ChannelType).ToString())); return(false); } break; case ChatChannelEnum.CHANNEL_PRIVATE_SEND: if (getTimeLeft(Client, ChannelType) < ChatTiming.getTime(ChannelType)) { Client.Send(new TextInformationMessage(TextInformationTypeEnum.UNK, 184)); return(false); } break; } return(true); }
public long getTimeEplased(WorldClient Client, ChatChannelEnum ChannelType) { return(Convert.ToInt32(Math.Ceiling((ChatTiming.getTime(ChannelType) - (Program.currentTimeMillis() - Client.myChatRestrictions[ChannelType])) / 1000d) + 1)); }
public long getTimeLeft(WorldClient Client, ChatChannelEnum ChannelType) { return(Program.currentTimeMillis() - Client.myChatRestrictions[ChannelType]); //return Convert.ToInt32(Math.Ceiling((Client.myChatRestrictions[ChannelType] - Environment.TickCount) / 1000d)); }
/// <summary> /// /// </summary> /// <param name="channel"></param> /// <param name="message"></param> /// <param name="whispedCharacter"></param> public override bool DispatchChatMessage(ChatChannelEnum channel, string message, CharacterEntity whispedCharacter = null) { if(channel == ChatChannelEnum.CHANNEL_PRIVATE_SEND) { if(whispedCharacter.Away || whispedCharacter.HasEnnemy(Pseudo)) { Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_PLAYER_AWAY_MESSAGE, whispedCharacter.Name)); return false; } if(Away) { Dispatch(WorldMessage.IM_INFO_MESSAGE(InformationEnum.INFO_YOU_ARE_AWAY_PLAYERS_CANT_RESPOND)); } } return base.DispatchChatMessage(channel, message, whispedCharacter); }
/// <summary> /// /// </summary> /// <param name="channel"></param> /// <param name="message"></param> /// <param name="whispedCharacter"></param> public virtual bool DispatchChatMessage(ChatChannelEnum channel, string message, CharacterEntity whispedCharacter = null) { var channelData = m_chatByChannel[channel]; if (channelData == null) return false; if (channel != ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE) { if (message.Equals(channelData.LastMessage, StringComparison.OrdinalIgnoreCase)) { Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_CHAT_SAME_MESSAGE)); return false; } channelData.LastMessage = message; if (UpdateTime < channelData.NextTime) { Dispatch(WorldMessage.IM_INFO_MESSAGE(InformationEnum.INFO_CHAT_SPAM_RESTRICTED, Math.Ceiling((channelData.NextTime - UpdateTime) * 0.001))); return false; } var delay = WorldConfig.CHAT_RESTRICTED_DELAY.ContainsKey(channel) ? WorldConfig.CHAT_RESTRICTED_DELAY[channel] : 0; channelData.NextTime = UpdateTime + delay; } var dispatcher = channelData.Dispatcher(); if (dispatcher != null) { switch (channel) { case ChatChannelEnum.CHANNEL_PRIVATE_SEND: case ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE: dispatcher(WorldMessage.CHAT_MESSAGE(channel, whispedCharacter.Id, whispedCharacter.Name, message)); break; default: dispatcher(WorldMessage.CHAT_MESSAGE(channel, Id, Name, message)); break; } } return true; }