当前位置: 首页>>代码示例>>C#>>正文


C# Player.ParseMessage方法代码示例

本文整理汇总了C#中fCraft.Player.ParseMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Player.ParseMessage方法的具体用法?C# Player.ParseMessage怎么用?C# Player.ParseMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fCraft.Player的用法示例。


在下文中一共展示了Player.ParseMessage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JoinHandler

        static void JoinHandler(Player player, Command cmd)
        {
            string worldName = cmd.Next();
            if (worldName == null)
            {
                CdJoin.PrintUsage(player);
                return;
            }

            if (worldName == "-")
            {
                if (player.LastUsedWorldName != null)
                {
                    worldName = player.LastUsedWorldName;
                }
                else
                {
                    player.Message("Cannot repeat world name: you haven't used any names yet.");
                    return;
                }
            }

            World[] worlds = WorldManager.FindWorlds(player, worldName);

            if (worlds.Length > 1)
            {
                player.MessageManyMatches("world", worlds);

            }
            else if (worlds.Length == 1)
            {
                World world = worlds[0];
                player.LastUsedWorldName = world.Name;
                switch (world.AccessSecurity.CheckDetailed(player.Info))
                {
                    case SecurityCheckResult.Allowed:
                    case SecurityCheckResult.WhiteListed:
                        if (world.IsFull)
                        {
                            player.Message("Cannot join {0}&S: world is full.", world.ClassyName);
                            return;
                        }
                        player.StopSpectating();
                        if (!player.JoinWorldNow(world, true, WorldChangeReason.ManualJoin))
                        {
                            player.Message("ERROR: Failed to join world. See log for details.");
                        }
                        break;
                    case SecurityCheckResult.BlackListed:
                        player.Message("Cannot join world {0}&S: you are blacklisted.",
                                        world.ClassyName);
                        break;
                    case SecurityCheckResult.RankTooLow:
                        player.Message("Cannot join world {0}&S: must be {1}+",
                                        world.ClassyName, world.AccessSecurity.MinRank.ClassyName);
                        break;
                }

            }
            else
            {
                // no worlds found - see if player meant to type in "/Join" and not "/TP"
                Player[] players = Server.FindPlayers(player, worldName, true);
                if (players.Length == 1)
                {
                    player.LastUsedPlayerName = players[0].Name;
                    player.StopSpectating();
                    player.ParseMessage("/TP " + players[0].Name, false, true);
                }
                else
                {
                    player.MessageNoWorld(worldName);
                }
            }
        }
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:75,代码来源:WorldCommands.cs

示例2: FBHandler

 static void FBHandler(Player player, Command cmd)
 {
     string name = cmd.Next();
     if (String.IsNullOrEmpty(name))
     {
         CdFreezeBring.PrintUsage(player);
         return;
     }
     else
     {
         Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);
         if (target == null)
         {
             return;
         }
         else
         {
             player.ParseMessage("/summon " + name, false, false); //to lazy to change target's coords, so ill just summon
             target.Info.IsFrozen = true;
             target.Message("&SYou have been frozen by {0}", player.ClassyName);
             return;
         }
     }
 }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:24,代码来源:ModerationCommands.cs

示例3: TPHandler

        static void TPHandler( Player player, Command cmd )
        {
            string name = cmd.Next();
            if( name == null ) {
                CdTP.PrintUsage( player );
                return;
            }

            if( cmd.Next() != null ) {
                cmd.Rewind();
                int x, y, z;
                if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {

                    if( x <= -1024 || x >= 1024 || y <= -1024 || y >= 1024 || z <= -1024 || z >= 1024 ) {
                        player.Message( "Coordinates are outside the valid range!" );

                    } else {
                        player.previousLocation = player.Position;
                        player.previousWorld = null;
                        player.TeleportTo( new Position {
                            X = (short)(x * 32 + 16),
                            Y = (short)(y * 32 + 16),
                            Z = (short)(z * 32 + 16),
                            R = player.Position.R,
                            L = player.Position.L
                        } );
                    }
                } else {
                    CdTP.PrintUsage( player );
                }

            } else {
                if( name == "-" ) {
                    if( player.LastUsedPlayerName != null ) {
                        name = player.LastUsedPlayerName;
                    } else {
                        player.Message( "Cannot repeat player name: you haven't used any names yet." );
                        return;
                    }
                }
                Player[] matches = Server.FindPlayers( player, name, true );
                if( matches.Length == 1 ) {
                    Player target = matches[0];
                    World targetWorld = target.World;
                    if( targetWorld == null ) PlayerOpException.ThrowNoWorld( target );

                    if( targetWorld == player.World ) {
                        player.previousLocation = player.Position;
                        player.previousWorld = null;
                        player.TeleportTo( target.Position );

                    } else {
                        switch( targetWorld.AccessSecurity.CheckDetailed( player.Info ) ) {
                            case SecurityCheckResult.Allowed:
                            case SecurityCheckResult.WhiteListed:
                                if( targetWorld.IsFull ) {
                                    player.Message( "Cannot teleport to {0}&S because world {1}&S is full.",
                                                    target.ClassyName,
                                                    targetWorld.ClassyName );
                                    return;
                                }
                                player.StopSpectating();
                                player.previousLocation = player.Position;
                                player.previousWorld = player.World;
                                player.JoinWorld( targetWorld, WorldChangeReason.Tp, target.Position );
                                break;
                            case SecurityCheckResult.BlackListed:
                                player.Message( "Cannot teleport to {0}&S because you are blacklisted on world {1}",
                                                target.ClassyName,
                                                targetWorld.ClassyName );
                                break;
                            case SecurityCheckResult.RankTooLow:
                                player.Message( "Cannot teleport to {0}&S because world {1}&S requires {2}+&S to join.",
                                                target.ClassyName,
                                                targetWorld.ClassyName,
                                                targetWorld.AccessSecurity.MinRank.ClassyName );
                                break;
                            // TODO: case PermissionType.RankTooHigh:
                        }
                    }

                } else if( matches.Length > 1 ) {
                    player.MessageManyMatches( "player", matches );

                } else {
                    // Try to guess if player typed "/TP" instead of "/Join"
                    World[] worlds = WorldManager.FindWorlds( player, name );

                    if( worlds.Length == 1 ) {
                        player.LastUsedWorldName = worlds[0].Name;
                        player.StopSpectating();
                        player.ParseMessage( "/Join " + worlds[0].Name, false, true );
                    } else {
                        player.MessageNoPlayer( name );
                    }
                }
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:98,代码来源:ModerationCommands.cs

示例4: Join

        internal static void Join( Player player, Command cmd ) {
            string worldName = cmd.Next();
            if( worldName == null ) {
                cdJoin.PrintUsage( player );
                return;
            }

            World[] worlds = WorldManager.FindWorlds( worldName );

            SearchingForWorldEventArgs e = new SearchingForWorldEventArgs( player, worldName, worlds.ToList(), true );
            WorldManager.RaiseSearchingForWorldEvent( e );
            worlds = e.Matches.ToArray();

            if( worlds.Length > 1 ) {
                player.ManyMatchesMessage( "world", worlds );

            } else if( worlds.Length == 1 ) {
                World world = worlds[0];
                switch( world.AccessSecurity.CheckDetailed( player.Info ) ) {
                    case SecurityCheckResult.Allowed:
                    case SecurityCheckResult.WhiteListed:
                        if( world.IsFull ) {
                            player.Message( "Cannot join {0}&S: world is full.", world.GetClassyName() );
                            return;
                        }
                        player.StopSpectating();
                        if( !player.Session.JoinWorldNow( world, false, true ) ) {
                            player.Message( "ERROR: Failed to join world. See log for details." );
                        }
                        break;
                    case SecurityCheckResult.BlackListed:
                        player.Message( "Cannot join world {0}&S: you are blacklisted",
                                        world.GetClassyName(), world.AccessSecurity.MinRank.GetClassyName() );
                        break;
                    case SecurityCheckResult.RankTooLow:
                        player.Message( "Cannot join world {0}&S: must be {1}+",
                                        world.GetClassyName(), world.AccessSecurity.MinRank.GetClassyName() );
                        break;
                }

            } else {
                // no worlds found - see if player meant to type in "/join" and not "/tp"
                Player[] players = Server.FindPlayers( player, worldName );
                if( players.Length == 1 ) {
                    player.StopSpectating();
                    player.ParseMessage( "/tp " + players[0].Name, false );
                } else {
                    player.NoWorldMessage( worldName );
                }
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:51,代码来源:WorldCommands.cs

示例5: LeBotHandler

		private static void LeBotHandler(Player player, CommandReader cmd) {
			string cmdchat = cmd.Next();
			string option = cmd.Next();
			string helper = cmd.Next();
			if (cmdchat == null) {
				player.Message(CdBot.Help);
				return;
			}
			if (option != null)
				option = option.ToLower();
			if (cmdchat != "<CalledFromChat>") {
				cmd.Rewind();
				option = cmd.Next().ToLower();
				helper = cmd.Next();
				player.ParseMessage(string.Format("Bot {0} {1}", option ?? "", helper ?? ""), (player == Player.Console));
                return;
			}
			if (player.Info.TimeSinceLastServerMessage.TotalSeconds < 5) {
				player.Info.getLeftOverTime(5, cmd);
				return;
			}
			if (option == null) {
				player.Message(CdBot.Help);
				return;
			}
            if (player.Info.TimesUsedBot == 0) {
                player.Message(
                    "&6Bot&f: This is your first time using &6Bot&s, I suggest you use \"/Help Bot\" to further understand how I work.");
            }
            bool sentMessage = true;
            switch (option) {
				case "go":
					Scheduler.NewTask(t => Server.BotMessage("5")).RunManual(TimeSpan.FromSeconds(0));
					Scheduler.NewTask(t => Server.BotMessage("4")).RunManual(TimeSpan.FromSeconds(1));
					Scheduler.NewTask(t => Server.BotMessage("3")).RunManual(TimeSpan.FromSeconds(2));
					Scheduler.NewTask(t => Server.BotMessage("2")).RunManual(TimeSpan.FromSeconds(3));
					Scheduler.NewTask(t => Server.BotMessage("1")).RunManual(TimeSpan.FromSeconds(4));
					Scheduler.NewTask(t => Server.BotMessage("Go!")).RunManual(TimeSpan.FromSeconds(5));
					break;
				case "server":
					Server.BotMessage("The name of this server is " + ConfigKey.ServerName.GetString() + ".");
					break;
				case "joke":
					FileInfo jokeList = new FileInfo("./Bot/Jokes.txt");
					string[] jokeStrings;
					if (jokeList.Exists) {
						jokeStrings = File.ReadAllLines("./Bot/Jokes.txt");
					} else {
						Server.BotMessage("I cannot tell a joke at this time!");
						return;
					}
					Random RandjokeString = new Random();
					string joker = jokeStrings[RandjokeString.Next(0, jokeStrings.Length)];
					Server.BotMessage(joker);
					break;
				case "idea":
					FileInfo adjectiveList = new FileInfo("./Bot/Adjectives.txt");
					FileInfo nounList = new FileInfo("./Bot/Nouns.txt");
					string[] adjectiveStrings;
					string[] nounStrings;
					if (adjectiveList.Exists && nounList.Exists) {
						adjectiveStrings = File.ReadAllLines("./Bot/Adjectives.txt");
						nounStrings = File.ReadAllLines("./Bot/Nouns.txt");
					} else {
						Server.BotMessage("I cannot tell you a build idea at this time!");
						return;
					}
					Random randAdjectiveString = new Random();
					Random randNounString = new Random();
					string adjective = adjectiveStrings[randAdjectiveString.Next(0, adjectiveStrings.Length)];
					string noun = nounStrings[randNounString.Next(0, nounStrings.Length)];
					string ana = "a";
					if (adjective.StartsWith("a") || adjective.StartsWith("e") || adjective.StartsWith("i") ||
						adjective.StartsWith("o") || adjective.StartsWith("u")) {
						ana = "an";
					} else if (noun.EndsWith("s")) {
						ana = "some";
					}
					Server.BotMessage("Build " + ana + " " + adjective + " " + noun);
					break;
				case "protip":
					FileInfo tipList = new FileInfo("./Bot/Protips.txt");
					string[] tipStrings;
					if (tipList.Exists) {
						tipStrings = File.ReadAllLines("./Bot/Protips.txt");
					} else {
						Server.BotMessage("I cannot tell a protip at this time!");
						return;
					}
					Random RandtipString = new Random();
					string tipper = tipStrings[RandtipString.Next(0, tipStrings.Length)];
					Server.BotMessage(tipper);
					break;
				case "time":
					TimeSpan time = player.Info.TotalTime;
					TimeSpan timenow = player.Info.TimeSinceLastLogin;
					if (helper == "total") {
						Server.BotMessage(player.ClassyName + "&f has spent a total of {0:F2} hours on this server.", time.TotalHours);
					} else {
						Server.BotMessage(player.ClassyName + "&f has played a total of {0:F2} minutes this session.", timenow.TotalMinutes);
//.........这里部分代码省略.........
开发者ID:Magi1053,项目名称:ProCraft,代码行数:101,代码来源:ModerationCommands.cs

示例6: EditHandler


//.........这里部分代码省略.........
                        break;
                    case "announcements":
                        if (File.Exists(Paths.AnnouncementsFileName))
                        {
                            File.Delete(Paths.AnnouncementsFileName);
                        }
                        File.Create(Paths.AnnouncementsFileName).Dispose();
                        player.Message("&eThe announcements for the server has been wiped.");
                        break;
                    default:
                        player.Message("&ePlease choose either 'greeting', 'rules', 'announcements' or 'swears' as an option to clear.");
                        break;
                }
                return;
            }

            else if (option == "add")
            {
                target = cmd.Next();
                if (String.IsNullOrEmpty(target))
                {
                    CdEdit.PrintUsage(player);
                    return;
                }

                //append the files
                string newItem = cmd.NextAll();
                if (String.IsNullOrEmpty(newItem))
                {
                    CdEdit.PrintUsage(player);
                    return;
                }
                switch (target.ToLower())
                {
                    case "swear":
                    case "swearwords":
                    case "swearword":
                    case "swears":
                        if (!File.Exists(Paths.SwearWordsFileName))
                        {
                            File.Create(Paths.SwearWordsFileName).Dispose();
                        }
                        using (StreamWriter sw = File.AppendText(Paths.SwearWordsFileName))
                        {
                            player.Message("&eAdded &c'{0}'&e to the list of swear words.", newItem);
                            sw.WriteLine(newItem);
                            sw.Close();
                        }
                        player.ParseMessage("/reload swears", true, false);
                        break;
                    case "rule":
                    case "rules":
                        if (!File.Exists(Paths.RulesFileName))
                        {
                            File.Create(Paths.RulesFileName).Dispose();
                        }
                        using (StreamWriter sw = File.AppendText(Paths.RulesFileName))
                        {
                            player.Message("&eAdded &c'{0}'&e to the /rules.", newItem);
                            sw.WriteLine(newItem);
                            sw.Close();
                        }
                        break;
                    case "announcement":
                    case "announcements":
                        if (!File.Exists(Paths.AnnouncementsFileName))
                        {
                            File.Create(Paths.AnnouncementsFileName).Dispose();
                        }
                        using (StreamWriter sw = File.AppendText(Paths.AnnouncementsFileName))
                        {
                            player.Message("&eAdded &c'{0}'&e to the announcements.", newItem);
                            sw.WriteLine(newItem);
                            sw.Close();
                        }
                        break;
                    case "greeting":
                        if (!File.Exists(Paths.GreetingFileName))
                        {
                            File.Create(Paths.GreetingFileName).Dispose();
                        }
                        //File.Create(Paths.GreetingFileName).Close();
                        using (StreamWriter sw = File.AppendText(Paths.GreetingFileName))
                        {
                            player.Message("&eChanged greeting to {0}.", newItem);
                            sw.WriteLine(newItem);
                            sw.Close();
                        }
                        break;
                    default:
                        player.Message("&ePlease choose either 'greeting', 'announcements', 'rules', or 'swears' as an option to add to.");
                        break;
                }
            }
            else
            {
                CdEdit.PrintUsage(player);
                return;
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:101,代码来源:MaintenanceCommands.cs

示例7: checkBotResponses

 static void checkBotResponses(Player player, string rawMessage) {
     if (player.Can(Permission.UseBot)) {
         if (rawMessage.StartsWith("Bot ", StringComparison.OrdinalIgnoreCase) && rawMessage.Length < 17) {
             player.ParseMessage("/bot <CalledFromChat> " + rawMessage.Remove(0, 4), false);
         }
         double BotTime = player.Info.TimeSinceLastServerMessage.TotalSeconds;
         if (LDistance(rawMessage.ToLower(), "how do i rank up?") <= 0.25
             || LDistance(rawMessage.ToLower(), "how do we rank up") <= 0.25) {
             if (BotTime > 5) {
                 Server.BotMessage("You rank up by building something nice, preferably big. Then ask a staff member for a review.");
                 player.Info.LastServerMessageDate = DateTime.Now;
                 player.Info.TimesUsedBot = (player.Info.TimesUsedBot + 1);
             }
         }
         if (LDistance(rawMessage.ToLower(), "who is the owner?") <= 0.25) {
             if (BotTime > 5) {
                 PlayerInfo owner;
                 if (PlayerDB.FindPlayerInfo(ConfigKey.ServerOwner.GetString(), out owner) && owner != null) {
                     Server.BotMessage("The owner is {0}", RankManager.HighestRank.Color + owner.Name);
                 } else {
                     Server.BotMessage("The owner is {0}", RankManager.HighestRank.Color + ConfigKey.ServerOwner.GetString());
                 }
                 player.Info.LastServerMessageDate = DateTime.Now;
                 player.Info.TimesUsedBot = (player.Info.TimesUsedBot + 1);
             }
         }
         if (LDistance(rawMessage.ToLower(), "what is this server called?") <= 0.25
             || LDistance(rawMessage.ToLower(), "what is the name of this server?") <= 0.25) {
             if (BotTime > 5) {
                 Server.BotMessage("The server name is: " + ConfigKey.ServerName.GetString());
                 player.Info.LastServerMessageDate = DateTime.Now;
                 player.Info.TimesUsedBot = (player.Info.TimesUsedBot + 1);
             }
         }
         if (LDistance(rawMessage.ToLower(), "where can i build?") <= 0.25
             || LDistance(rawMessage.ToLower(), "where do we build") <= 0.25) {
             if (BotTime > 5) {
                 Server.BotMessage("You can build anywhere outside of spawn. Just not on another persons build unless they say you can. ");
                 player.Info.LastServerMessageDate = DateTime.Now;
                 player.Info.TimesUsedBot = (player.Info.TimesUsedBot + 1);
             }
         }
         if (LDistance(rawMessage.ToLower(), "what is my next rank?") <= 0.25 ||
             LDistance(rawMessage.ToLower(), "what rank is after this one?") <= 0.25) {
             Rank meh = player.Info.Rank.NextRankUp;
             if (BotTime > 5 && player.Info.Rank != RankManager.HighestRank) {
             tryagain:
                 if (meh.IsDonor) {
                     meh = meh.NextRankUp;
                     goto tryagain;
                 }
                 Server.BotMessage("Your next rank is: " + meh.ClassyName);
                 player.Info.LastServerMessageDate = DateTime.Now;
                 player.Info.TimesUsedBot = (player.Info.TimesUsedBot + 1);
             } else if (player.Info.Rank == RankManager.HighestRank) {
                 Server.BotMessage("You are already the highest rank.");
                 player.Info.LastServerMessageDate = DateTime.Now;
                 player.Info.TimesUsedBot = (player.Info.TimesUsedBot + 1);
             }
         }
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:62,代码来源:Chat.cs

示例8: CancelHandler

 static void CancelHandler( Player player, Command cmd )
 {
     if( cmd.HasNext ) {
         CdCancel.PrintUsage( player );
         return;
     }
     if( player.IsMakingSelection ) {
         player.SelectionCancel();
         player.MessageNow( "Selection cancelled." );
         player.ParseMessage("/nvm", false, false);//LOL lazy
     } else {
         player.MessageNow( "There is currently nothing to cancel." );
     }
 }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:14,代码来源:BuildingCommands.cs

示例9: AbortAllHandler

 static void AbortAllHandler( Player player, Command cmd )
 {
     player.IsPainting = false;			// /paint
     player.ResetAllBinds();				// /bind
     player.ParseMessage( "/brush normal", false, false );  // /brush (totally not a sneaky way to do this)
     player.BuildingPortal = false;			// /portal
     player.fireworkMode = false;			// /fireworks
     player.GunMode = false;				// /gun
     player.IsRepeatingSelection = false;		// /static
     player.SelectionCancel();			// /cancel
     player.StopSpectating();			// /spectate
     player.towerMode = false;			// /tower
     player.ParseMessage( "/nvm", false, false );		// /nvm
 }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:14,代码来源:BuildingCommands.cs

示例10: greetHandler

 private static void greetHandler(Player player, CommandReader cmd) {
     var all = Server.Players.Where(p => !p.Info.IsHidden).OrderBy(p => p.Info.TimeSinceLastLogin.ToMilliSeconds());
     if (all.Any() && all != null) {
         Player last = all.First();
         if (last == player) {
             player.Message("You were the last player to join silly");
             return;
         }
         if (player.Info.LastPlayerGreeted == last) {
             player.Message("You have to greet someone else before you can greet {0} again.", last.Name);
             return;
         }
         string message = "Welcome to " + Color.StripColors(ConfigKey.ServerName.GetString()) + ", " + last.Name + "!";
         player.ParseMessage(message, false);
         player.Info.LastServerMessageDate = DateTime.Now;
         player.Info.LastPlayerGreeted = last;
     } else {
         player.Message("Error: No one else on!");
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:20,代码来源:ChatCommands.cs


注:本文中的fCraft.Player.ParseMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。