本文整理汇总了C#中fCraft.Events.ChatSendingEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# ChatSendingEventArgs类的具体用法?C# ChatSendingEventArgs怎么用?C# ChatSendingEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChatSendingEventArgs类属于fCraft.Events命名空间,在下文中一共展示了ChatSendingEventArgs类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendWorld
/// <summary> Sends world/local chat message. </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was canceled by an event callback. </returns>
/// <exception cref="ArgumentNullException"> If player or rawMessage is null. </exception>
public static bool SendWorld( [NotNull] Player player, [NotNull] string rawMessage ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( rawMessage == null ) throw new ArgumentNullException( "rawMessage" );
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
var recipientList = playerWorld.Players
.NotIgnoring( player );
string formattedMessage = String.Format( "({0}&F){1}: {2}",
playerWorld.ClassyName,
player.ClassyName,
rawMessage );
var e = new ChatSendingEventArgs( player,
rawMessage,
formattedMessage,
ChatMessageType.World,
recipientList );
if( !SendInternal( e ) ) return false;
Logger.Log( LogType.GlobalChat,
"(world {0}){1}: {2}",
playerWorld.Name, player.Name, rawMessage );
return true;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:32,代码来源:Chat.cs
示例2: ChatSending
public static void ChatSending( object sender, ChatSendingEventArgs e )
{
if ( e.MessageType == ChatMessageType.Global ) {
if ( e.Message == null )
return;
if ( e.Player == null )
return;
//Parse greentext
if ( e.Message.Length > 1 && e.MessageType == ChatMessageType.Global ) {
if ( e.Message.StartsWith( ">" ) && e.Message[1] != ' ' ) {
e.FormattedMessage = String.Format( "{0}&F: {1}{2}", e.Player.ClassyName, Color.Lime, e.Message );
return;
}
}
//Parse all others
string Message = e.Message; //use only e.Message so you don't accidentally highlight user names ect
Message = HighlightSections( Message );
e.FormattedMessage = String.Format( "{0}&F: {1}", e.Player.ClassyName, Message ); //reformat the message
}
}
开发者ID:Jonty800,项目名称:HashTagSwag,代码行数:21,代码来源:PluginClass.cs
示例3: SendPM
/// <summary> Sends a private message (PM). Does NOT send a copy of the message to the sender. </summary>
/// <param name="from"> Sender player. </param>
/// <param name="to"> Recepient player. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendPM( [NotNull] Player from, [NotNull] Player to, [NotNull] string rawMessage ) {
if( from == null ) throw new ArgumentNullException( "from" );
if( to == null ) throw new ArgumentNullException( "to" );
if( rawMessage == null ) throw new ArgumentNullException( "rawMessage" );
var recepientList = new[] { to };
string formattedMessage = String.Format( "&Pfrom {0}: {1}",
from.Name, rawMessage );
var e = new ChatSendingEventArgs( from,
rawMessage,
formattedMessage,
ChatMessageType.PM,
recepientList );
if( !SendInternal( e ) ) return false;
Logger.Log( LogType.PrivateChat,
"{0} to {1}: {2}",
from.Name, to.Name, rawMessage );
return true;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:27,代码来源:Chat.cs
示例4: SendMe
/// <summary> Sends an action message (/Me). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendMe( [NotNull] Player player, [NotNull] string rawMessage ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( rawMessage == null ) throw new ArgumentNullException( "rawMessage" );
var recepientList = Server.Players.NotIgnoring( player );
string formattedMessage = String.Format( "&M*{0} {1}",
player.Name,
rawMessage );
var e = new ChatSendingEventArgs( player,
rawMessage,
formattedMessage,
ChatMessageType.Me,
recepientList );
if( !SendInternal( e ) ) return false;
Logger.Log( LogType.GlobalChat,
"(me){0}: {1}", player.Name, rawMessage );
return true;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:26,代码来源:Chat.cs
示例5: SendGlobal
/// <summary> Sends a global (white) chat. </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendGlobal([NotNull] Player player, [NotNull] string rawMessage)
{
if (player == null) throw new ArgumentNullException("player");
if (rawMessage == null) throw new ArgumentNullException("rawMessage");
rawMessage = rawMessage.Replace("$motd", ConfigKey.MOTD.GetString());
rawMessage = rawMessage.Replace("$time", DateTime.Now.ToString()); //used to test env realistic
var recepientList = Server.Players.NotIgnoring(player);
// Check caps
if (!player.Can(Permission.ChatWithCaps))
{
int caps = 0;
for (int i = 0; i < rawMessage.Length; i++)
{
if (Char.IsUpper(rawMessage[i]))
{
caps++;
if (caps > ConfigKey.MaxCaps.GetInt())
{
rawMessage = rawMessage.ToLower();
player.Message("Your message was changed to lowercase as it exceeded the maximum amount of capital letters.");
}
}
}
}
if (player.IsStaticStaff)
{
recepientList = Server.Players.Can(Permission.ReadStaffChat)
.NotIgnoring(player)
.Union(player);
rawMessage = rawMessage.Replace(rawMessage, "&P(staff)" + player.ClassyName + "&P: " + rawMessage);
}
// Swear filter
if (!player.Can(Permission.Swear))
{
if (!File.Exists("SwearWords.txt"))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("#This txt file should be filled with bad words that you want to be filtered out");
sb.AppendLine("#I have included some examples, excuse my language :P");
sb.AppendLine("fuck");
sb.AppendLine("fucking");
sb.AppendLine("fucked");
sb.AppendLine("dick");
sb.AppendLine("bitch");
sb.AppendLine("shit");
sb.AppendLine("shitting");
sb.AppendLine("shithead");
sb.AppendLine("cunt");
sb.AppendLine("nigger");
sb.AppendLine("wanker");
sb.AppendLine("wank");
sb.AppendLine("wanking");
sb.AppendLine("piss");
File.WriteAllText("SwearWords.txt", sb.ToString());
}
string CensoredText = Color.ReplacePercentCodes(ConfigKey.SwearReplace.GetString())+"&F";
if (ConfigKey.SwearReplace.GetString() == null)
{
CensoredText = "&CBlock&F";
}
const string PatternTemplate = @"\b({0})(s?)\b";
const RegexOptions Options = RegexOptions.IgnoreCase;
if (Swears.Count == 0)
{
Swears.AddRange(File.ReadAllLines("SwearWords.txt").Where(line => line.StartsWith("#") == false || line.Trim().Equals(String.Empty)));
}
if (badWordMatchers == null)
{
badWordMatchers = Swears.
Select(x => new Regex(string.Format(PatternTemplate, x), Options));
}
string output = badWordMatchers.
Aggregate(rawMessage, (current, matcher) => matcher.Replace(current, CensoredText));
rawMessage = output;
}
string formattedMessage = String.Format("{0}&F: {1}",
player.ClassyName,
rawMessage);
var e = new ChatSendingEventArgs(player,
rawMessage,
formattedMessage,
ChatMessageType.Global,
recepientList);
//.........这里部分代码省略.........
开发者ID:Desertive,项目名称:800craft,代码行数:101,代码来源:Chat.cs
示例6: SendGlobal
/// <summary> Sends a global (white) chat. </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendGlobal( [NotNull] Player player, [NotNull] string rawMessage ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( rawMessage == null ) throw new ArgumentNullException( "rawMessage" );
string OriginalMessage = rawMessage;
if (Server.Moderation && !Server.VoicedPlayers.Contains(player) && player.World != null)
{
player.Message("&WError: Server Moderation is activated. Message failed to send");
return false;
}
rawMessage = rawMessage.Replace("$name", "Hello my name is " + player.ClassyName);
rawMessage = rawMessage.Replace("$kicks", "I have kicked " + player.Info.TimesKickedOthers.ToString() + " players.");
rawMessage = rawMessage.Replace("$bans", "I have banned " + player.Info.TimesBannedOthers.ToString() + " players.");
rawMessage = rawMessage.Replace("$awesome", "It is my professional opinion, that " + ConfigKey.ServerName.GetString() + " is the best server on Minecraft");
rawMessage = rawMessage.Replace("$server", ConfigKey.ServerName.GetString());
rawMessage = rawMessage.Replace("$motd", ConfigKey.MOTD.GetString());
rawMessage = rawMessage.Replace("$date", DateTime.UtcNow.ToShortDateString());
rawMessage = rawMessage.Replace("$time", DateTime.Now.ToString());
if (!player.Can(Permission.ChatWithCaps))
{
int caps = 0;
for (int i = 0; i < rawMessage.Length; i++)
{
if (Char.IsUpper(rawMessage[i]))
{
caps++;
if (caps > ConfigKey.MaxCaps.GetInt())
{
rawMessage = rawMessage.ToLower();
player.Message("Your message was changed to lowercase as it exceeded the maximum amount of capital letters.");
}
}
}
}
if (!player.Can(Permission.Swear))
{
if (!File.Exists("SwearWords.txt"))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("#This txt file should be filled with bad words that you want to be filtered out");
sb.AppendLine("#I have included some examples, excuse my language :P");
sb.AppendLine("fuck");
sb.AppendLine("fucking");
sb.AppendLine("fucked");
sb.AppendLine("dick");
sb.AppendLine("bitch");
sb.AppendLine("shit");
sb.AppendLine("shitting");
sb.AppendLine("shithead");
sb.AppendLine("cunt");
sb.AppendLine("nigger");
sb.AppendLine("wanker");
sb.AppendLine("wank");
sb.AppendLine("wanking");
sb.AppendLine("piss");
File.WriteAllText("SwearWords.txt", sb.ToString());
}
string CensoredText = Color.ReplacePercentCodes(ConfigKey.SwearName.GetString()) + Color.White;
if (ConfigKey.SwearName.GetString() == null)
{
CensoredText = "&CBlock&F";
}
const string PatternTemplate = @"\b({0})(s?)\b";
const RegexOptions Options = RegexOptions.IgnoreCase;
if (Swears.Count == 0)
{
Swears.AddRange(File.ReadAllLines("SwearWords.txt").
Where(line => line.StartsWith("#") == false || line.Trim().Equals(String.Empty)));
}
if (badWordMatchers == null)
{
badWordMatchers = Swears.
Select(x => new Regex(string.Format(PatternTemplate, x), Options));
}
string output = badWordMatchers.
Aggregate(rawMessage, (current, matcher) => matcher.Replace(current, CensoredText));
rawMessage = output;
}
var recepientList = Server.Players.NotIgnoring(player);
string formattedMessage = String.Format( "{0}&F: {1}",
player.ClassyName,
rawMessage );
var e = new ChatSendingEventArgs( player,
rawMessage,
formattedMessage,
ChatMessageType.Global,
recepientList );
//.........这里部分代码省略.........
开发者ID:727021,项目名称:800craft,代码行数:101,代码来源:Chat.cs
示例7: SendSay
/// <summary> Sends a global announcement (/Say). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendSay( [NotNull] Player player, [NotNull] string rawMessage ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( rawMessage == null ) throw new ArgumentNullException( "rawMessage" );
var recepientList = Server.Players;
string formattedMessage = Color.Say + rawMessage;
var e = new ChatSendingEventArgs( player,
rawMessage,
formattedMessage,
ChatMessageType.Say,
recepientList );
if( !SendInternal( e ) ) return false;
Logger.Log( LogType.GlobalChat,
"(say){0}: {1}", player.Name, rawMessage );
return true;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:24,代码来源:Chat.cs
示例8: RaiseSentEvent
static void RaiseSentEvent( ChatSendingEventArgs args, int count )
{
var h = Sent;
if( h != null ) h( null, new ChatSentEventArgs( args.Player, args.Message, args.FormattedMessage,
args.MessageType, args.RecepientList, count ) );
}
开发者ID:Desertive,项目名称:800craft,代码行数:6,代码来源:Chat.cs
示例9: IRCSendStaff
/// <summary> Sends a staff message from irc (!St). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool IRCSendStaff([NotNull] string player, [NotNull] string rawMessage)
{
if (player == null) throw new ArgumentNullException("player");
if (rawMessage == null) throw new ArgumentNullException("rawMessage");
var recipientList = Server.Players.Can(Permission.ReadStaffChat).Where(p => p.Info.ReadIRC == true);
string formattedMessage = String.Format("&P(IRC+staff)&5(IRC){0}&P: {1}",
player,
rawMessage);
var e = new ChatSendingEventArgs( Player.Console,
rawMessage,
formattedMessage,
ChatMessageType.Staff,
recipientList);
if (!SendInternal(e)) return false;
IRC.SendChannelMessage("\u211C\u212C(IRC+Staff)(IRC)\u211C" + player + ": " + rawMessage);
Logger.Log(LogType.GlobalChat,
"(IRC+staff)(IRC){0}: {1}",
player,
rawMessage);
return true;
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:30,代码来源:Chat.cs
示例10: SendIRCStaff
/// <summary> Sends a staff message (/IRCStaff). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendIRCStaff([NotNull] Player player, [NotNull] string rawMessage)
{
if (player == null) throw new ArgumentNullException("player");
if (rawMessage == null) throw new ArgumentNullException("rawMessage");
var recipientList = Server.Players.Can(Permission.ReadStaffChat)
.NotIgnoring(player)
.Union(player);
string formattedMessage = String.Format("&P(IRC+staff){0}&P: {1}",
player.Name,
rawMessage);
var e = new ChatSendingEventArgs(player,
rawMessage,
formattedMessage,
ChatMessageType.Staff,
recipientList);
IRC.SendChannelMessage("\u212C(IRC+Staff)\u211C" + player.Name + ": " + rawMessage);
if (!SendInternal(e)) return false;
Logger.Log(LogType.GlobalChat,
"(IRC+staff){0}: {1}",
player.Name,
rawMessage);
return true;
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:33,代码来源:Chat.cs
示例11: SendStaffSay
/// <summary> Sends a global announcement to staff (/StaffSay). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendStaffSay([NotNull] Player player, [NotNull] string rawMessage) {
if (player == null)
throw new ArgumentNullException("player");
if (rawMessage == null)
throw new ArgumentNullException("rawMessage");
var recepientList = Server.Players.Where(p => p.Info.Rank != RankManager.HighestRank).Can(Permission.ReadStaffChat);
string formattedMessage = Color.Say + rawMessage;
var e = new ChatSendingEventArgs(player, rawMessage, formattedMessage, ChatMessageType.Staff, recepientList);
if (!SendInternal(e))
return false;
var recepientListOwner = Server.Players.Where(p => p.Info.Rank == RankManager.HighestRank);
string formattedMessageOwner = "&s[&yStaffSay&s][&f" + player.Name + "&s] &Y" + rawMessage;
var eo = new ChatSendingEventArgs(player, rawMessage, formattedMessageOwner, ChatMessageType.StaffSayOwner, recepientListOwner);
if (!SendInternal(eo))
return false;
Logger.Log(LogType.GlobalChat, "(staff_say){0}: {1}", player.Name, rawMessage);
return true;
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:25,代码来源:Chat.cs
示例12: SendSay
/// <summary> Sends a global announcement (/Say). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendSay([NotNull] Player player, [NotNull] string rawMessage) {
if (player == null)
throw new ArgumentNullException("player");
if (rawMessage == null)
throw new ArgumentNullException("rawMessage");
var recepientList = Server.Players.Where(p => !p.IsStaff);
string formattedMessage = Color.Say + rawMessage;
var e = new ChatSendingEventArgs(player, rawMessage, formattedMessage, ChatMessageType.Say, recepientList);
if (!SendInternal(e))
return false;
var recepientListStaff = Server.Players.Can(Permission.ReadStaffChat);
string formattedMessageStaff = "&s[&YSay&s][&f" + player.Name + "&s] &Y" + rawMessage;
var es = new ChatSendingEventArgs(player, rawMessage, formattedMessageStaff, ChatMessageType.SayStaff, recepientListStaff);
if (!SendInternal(es))
return false;
Logger.Log(LogType.GlobalChat,
"(say){0}: {1}", player.Name, rawMessage);
return true;
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:27,代码来源:Chat.cs
示例13: SendGlobal
//.........这里部分代码省略.........
sb.AppendLine("#This txt file should be filled with bad words that you want to be filtered out");
sb.AppendLine("#I have included some examples, excuse my language :P");
sb.AppendLine("fuck");
sb.AppendLine("fucking");
sb.AppendLine("fucked");
sb.AppendLine("dick");
sb.AppendLine("bitch");
sb.AppendLine("shit");
sb.AppendLine("shitting");
sb.AppendLine("shithead");
sb.AppendLine("cunt");
sb.AppendLine("nigger");
sb.AppendLine("wanker");
sb.AppendLine("wank");
sb.AppendLine("wanking");
sb.AppendLine("piss");
File.WriteAllText("SwearWords.txt", sb.ToString());
}
string CensoredText = Color.ReplacePercentCodes(ConfigKey.SwearName.GetString()) + Color.White;
if (ConfigKey.SwearName.GetString() == null)
{
CensoredText = "&CBlock&F";
}
const string PatternTemplate = @"\b({0})(s?)\b";
const RegexOptions Options = RegexOptions.IgnoreCase;
if (Swears.Count == 0)
{
Swears.AddRange(File.ReadAllLines("SwearWords.txt").
Where(line => line.StartsWith("#") == false || line.Trim().Equals(String.Empty)));
}
if (badWordMatchers == null)
{
badWordMatchers = Swears.
Select(x => new Regex(string.Format(PatternTemplate, x), Options));
}
string output = badWordMatchers.
Aggregate(rawMessage, (current, matcher) => matcher.Replace(current, CensoredText));
rawMessage = output;
}
/*if (player.World != null)
{
if (player.World.GameOn)
{
if (Games.MineChallenge.mode == Games.MineChallenge.GameMode.math1)
{
if (rawMessage == Games.MineChallenge.answer.ToString() && !Games.MineChallenge.completed.Contains(player))
{
Games.MineChallenge.completed.Add(player);
player.Message("&8Correct!");
if (player.World.blueTeam.Contains(player)) player.World.blueScore++;
else player.World.redScore++;
}
else
{
player.Message("&8Incorrect");
}
return false;
}
if (Games.MineChallenge.mode == Games.MineChallenge.GameMode.math2)
{
if (rawMessage == Games.MineChallenge.answer.ToString() && !Games.MineChallenge.completed.Contains(player))
{
Games.MineChallenge.completed.Add(player);
player.Message("&8Correct!");
if (player.World.blueTeam.Contains(player)) player.World.blueScore++;
else player.World.redScore++;
}
else
{
player.Message("&8Incorrect");
}
return false;
}
}
}*/
var recepientList = Server.Players.NotIgnoring(player); if (player.World.WorldOnlyChat) recepientList = player.World.Players.NotIgnoring(player);
string formattedMessage = String.Format( "{0}&F: {1}",
player.ClassyName,
rawMessage );
var e = new ChatSendingEventArgs( player,
rawMessage,
formattedMessage,
ChatMessageType.Global,
recepientList );
if( !SendInternal( e ) ) return false;
Logger.Log( LogType.GlobalChat,
"{0}: {1}", player.Name, OriginalMessage );
return true;
}
开发者ID:zINaPalm,项目名称:LegendCraftSource,代码行数:101,代码来源:Chat.cs
示例14: ChatSentEventArgs
internal ChatSentEventArgs( ChatSendingEventArgs e, int recipientCount ) {
Player = e.Player;
Message = e.Message;
MessageType = e.MessageType;
RecipientList = e.RecipientList;
FormattedMessage = e.FormattedMessage;
RecipientCount = recipientCount;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:Chat.cs
示例15: SendRank
/// <summary> Sends a rank-wide message (@@Rank message). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rank"> Target rank. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendRank( [NotNull] Player player, [NotNull] Rank rank, [NotNull] string rawMessage )
{
if( player == null ) throw new ArgumentNullException( "player" );
if( rank == null ) throw new ArgumentNullException( "rank" );
if( rawMessage == null ) throw new ArgumentNullException( "rawMessage" );
var recepientList = rank.Players.NotIgnoring( player ).Union( player );
string formattedMessage = String.Format( "&P({0}&P){1}: {2}",
rank.ClassyName,
player.Name,
rawMessage );
var e = new ChatSendingEventArgs( player,
rawMessage,
formattedMessage,
ChatMessageType.Rank,
recepientList );
if( !SendInternal( e ) ) return false;
Logger.Log( LogType.RankChat,
"(rank {0}){1}: {2}",
rank.Name, player.Name, rawMessage );
return true;
}
开发者ID:Desertive,项目名称:800craft,代码行数:31,代码来源:Chat.cs
示例16: RaiseSendingEvent
static bool RaiseSendingEvent( ChatSendingEventArgs args )
{
var h = Sending;
if( h == null ) return false;
h( null, args );
return args.Cancel;
}
开发者ID:Desertive,项目名称:800craft,代码行数:7,代码来源:Chat.cs
示例17: SendGlobal
/// <summary> Sends a global (white) chat. </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendGlobal([NotNull] Player player, [NotNull] string rawMessage) {
if (player == null) throw new ArgumentNullException("player");
if (rawMessage == null) throw new ArgumentNullException("rawMessage");
foreach (Filter Swear in Filters) {
if (rawMessage.ToLower().Contains(Swear.Word.ToLower())) {
rawMessage = rawMessage.ReplaceString(Swear.Word, Swear.Replacement, StringComparison.InvariantCultureIgnoreCase);
}
}
if (!player.IsStaff) {
rawMessage = RegexIPMatcher.Replace(rawMessage, "<Redacted IP>");
}
if (rawMessage.Length >= 10 && player.Info.Rank.MaxCaps > 0) {
int caps = 0;
for (int i = 0; i < rawMessage.Length; i++) {
if (char.IsUpper(rawMessage[i])) {
caps++;
}
}
if (player.Info.Rank.MaxCaps == 1) {
if (caps > (rawMessage.Length / 2)) {
rawMessage = rawMessage.ToLower().UppercaseFirst();
player.Message("Max uppercase letters reached. Message set to lowercase");
}
} else if (caps > player.Info.Rank.MaxCaps) {
rawMessage = rawMessage.ToLower().UppercaseFirst();
player.Message("Max uppercase letters reached. Message set to lowercase");
}
}
if (player.Info.ChatRainbows) {
rawMessage = Rainbow.Rainbowize(rawMessage);
} else if (player.Info.ChatBWRainbows) {
rawMessage = Rainbow.BWRainbowize(rawMessage);
}
var recipientList = Server.Players.NotIgnoring(player);
string formattedMessage = string.Format("{0}&F: {1}",
player.ClassyName,
rawMessage);
var e = new ChatSendingEventArgs(player,
rawMessage,
formattedMessage,
ChatMessageType.Global,
recipientList);
if (!SendInternal(e)) return false;
rawMessage = Color.StripColors(rawMessage);
checkBotResponses(player, rawMessage);
Logger.Log(LogType.GlobalChat,
"(global){0}: {1}", player.Info.Rank.Color + player.Name + Color.White, rawMessage);
return true;
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:60,代码来源:Chat.cs
示例18: SendAdmin
public static bool SendAdmin(Player player, string rawMessage)
{
if (player == null) throw new ArgumentNullException("player");
if (rawMessage == null) throw new ArgumentNullException("rawMessage");
var recepientList = Server.Players.Can(Permission.ReadAdminChat)
.NotIgnoring(player);
string formattedMessage = String.Format("&9(Admin){0}&b: {1}",
player.ClassyName,
rawMessage);
var e = new ChatSendingEventArgs(player,
rawMessage,
formattedMessage,
ChatMessageType.Staff,
recepientList);
if (!SendInternal(e)) return false;
Logger.Log(LogType.GlobalChat, "(Admin){0}: {1}", player.Name, rawMessage);
return true;
}
开发者ID:Desertive,项目名称:800craft,代码行数:23,代码来源:Chat.cs
示例19: SendWorld
/// <summary> Sends a world-specific message (!World message). </summary>
/// <param name="player"> Player writing the message. </param>
/// <param name="world"> Target world. </param>
/// <param name="rawMessage"> Message text. </param>
/// <returns> True if message was sent, false if it was cancelled by an event callback. </returns>
public static bool SendWorld([NotNull] Player player, [NotNull] World world, [NotNull] string rawMessage)
{
if (player == null) throw new ArgumentNullException("player");
if (world == null)
{
if (player.World == null)
{
player.Message("Please specify a world name when using WorldChat from console.");
return false;
}
}
if (rawMessage == null) throw new ArgumentNullException("rawMessage");
var recepientList = world.Players.NotIgnoring(player).Union(player);
string formattedMessage = String.Format("&P({0}&P){1}: {2}", world.ClassyName, player.Name, rawMessage);
var e = new ChatSendingEventArgs(player,
rawMessage,
formattedMessage,
ChatMessageType.World, recepientList);
if (!SendInternal(e)) return false;
Logger.Log(LogType.GlobalChat, "({0}){1}: {2}", world.Name, player.Name, rawMessage);
return true;
}
开发者ID: |
请发表评论