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


C# CommandReader.NextInt方法代码示例

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


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

示例1: MarkHandler

        static void MarkHandler( Player player, CommandReader cmd ) {
            Map map = player.WorldMap;
            int x, y, z;
            Vector3I coords;
            if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {
                if( cmd.HasNext ) {
                    CdMark.PrintUsage( player );
                    return;
                }
                coords = new Vector3I( x, y, z );
            } else {
                coords = player.Position.ToBlockCoords();
            }
            coords.X = Math.Min( map.Width - 1, Math.Max( 0, coords.X ) );
            coords.Y = Math.Min( map.Length - 1, Math.Max( 0, coords.Y ) );
            coords.Z = Math.Min( map.Height - 1, Math.Max( 0, coords.Z ) );

            if( player.SelectionMarksExpected > 0 ) {
                player.SelectionAddMark( coords, true, true );
            } else {
                player.MessageNow( "Cannot mark - no selection in progress." );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:23,代码来源:BuildingCommands.cs

示例2: IdeaHandler

        private static void IdeaHandler(Player player, CommandReader cmd) {
            string[] adjectiveStrings;
            string[] nounStrings;
            if (File.Exists("./Bot/Adjectives.txt") && File.Exists("./Bot/Nouns.txt")) {
                adjectiveStrings = File.ReadAllLines("./Bot/Adjectives.txt");
                nounStrings = File.ReadAllLines("./Bot/Nouns.txt");
            } else {
                player.Message(
                    "&cError: No idea files! This should not happen! Yell at the host for deleting Adjectives.txt and Nouns.txt in the bot file.");
                return;
            }
            Random randAdjectiveString = new Random();
            Random randNounString = new Random();
            string adjective;
            string noun;
            int amount;
            string ana = "a";
            if (player.Info.TimeSinceLastServerMessage.TotalSeconds < 5) {
                player.Info.getLeftOverTime(5, cmd);
                return;
            }

            if (cmd.NextInt(out amount)) {
                if (amount > 10)
                    amount = 10;
                if (amount < 1)
                    amount = 1;
                player.Message("{0} random building ideas", amount);
                for (int i = 1; i <= amount;) {
                    adjective = adjectiveStrings[randAdjectiveString.Next(0, adjectiveStrings.Length)];
                    noun = nounStrings[randNounString.Next(0, nounStrings.Length)];
                    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";
                    }
                    player.Message("&sIdea #{0}&f: Build " + ana + " " + adjective + " " + noun, i);
                    i++;
                    ana = "a";
                }
            } else {
                adjective = adjectiveStrings[randAdjectiveString.Next(0, adjectiveStrings.Length)];
                noun = nounStrings[randNounString.Next(0, nounStrings.Length)];
                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";
                }
                player.Message("&sIdea&f: Build " + ana + " " + adjective + " " + noun);
            }
            player.Info.LastServerMessageDate = DateTime.Now;
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:54,代码来源:ChatCommands.cs

示例3: EmotesHandler

        static void EmotesHandler( Player player, CommandReader cmd ) {
            int page = 1;
            if( cmd.HasNext ) {
                if( !cmd.NextInt( out page ) ) {
                    CdEmotes.PrintUsage( player );
                    return;
                }
            }
            if( page < 1 || page > 3 ) {
                CdEmotes.PrintUsage( player );
                return;
            }

            var emoteChars = Chat.EmoteKeywords
                                 .Values
                                 .Distinct()
                                 .Skip( ( page - 1 ) * 11 )
                                 .Take( 11 );

            player.Message( "List of emotes, page {0} of 3:", page );
            foreach( char ch in emoteChars ) {
                char ch1 = ch;
                string keywords = Chat.EmoteKeywords
                                      .Where( pair => pair.Value == ch1 )
                                      .Select( kvp => "{&F" + kvp.Key.UppercaseFirst() + "&7}" )
                                      .JoinToString( " " );
                player.Message( "&F  {0} &7= {1}", ch, keywords );
            }

            if( !player.Can( Permission.UseEmotes ) ) {
                Rank reqRank = RankManager.GetMinRankWithAllPermissions( Permission.UseEmotes );
                if( reqRank == null ) {
                    player.Message( "&SNote: None of the ranks have permission to use emotes." );
                } else {
                    player.Message( "&SNote: only {0}+&S can use emotes in chat.",
                             reqRank.ClassyName );
                }
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:39,代码来源:InfoCommands.cs

示例4: PlayersHandler

        static void PlayersHandler( Player player, CommandReader cmd ) {
            string param = cmd.Next();
            Player[] players;
            string worldName = null;
            string qualifier;
            int offset = 0;

            if( param == null || Int32.TryParse( param, out offset ) ) {
                // No world name given; Start with a list of all players.
                players = Server.Players;
                qualifier = "online";
                if( cmd.HasNext ) {
                    CdPlayers.PrintUsage( player );
                    return;
                }

            } else {
                // Try to find the world
                World world = WorldManager.FindWorldOrPrintMatches( player, param );
                if( world == null ) return;

                worldName = param;
                // If found, grab its player list
                players = world.Players;
                qualifier = String.Format( "in world {0}&S", world.ClassyName );

                if( cmd.HasNext && !cmd.NextInt( out offset ) ) {
                    CdPlayers.PrintUsage( player );
                    return;
                }
            }

            if( players.Length > 0 ) {
                // Filter out hidden players, and sort
                Player[] visiblePlayers = players.Where( player.CanSee )
                                                 .OrderBy( p => p, PlayerListSorter.Instance )
                                                 .ToArray();


                if( visiblePlayers.Length == 0 ) {
                    player.Message( "There are no players {0}", qualifier );

                } else if( visiblePlayers.Length <= PlayersPerPage || player.IsSuper ) {
                    player.MessagePrefixed( "&S  ", "&SThere are {0} players {1}: {2}",
                                            visiblePlayers.Length, qualifier, visiblePlayers.JoinToClassyString() );

                } else {
                    if( offset >= visiblePlayers.Length ) {
                        offset = Math.Max( 0, visiblePlayers.Length - PlayersPerPage );
                    }
                    Player[] playersPart = visiblePlayers.Skip( offset ).Take( PlayersPerPage ).ToArray();
                    player.MessagePrefixed( "&S   ", "&SPlayers {0}: {1}",
                                            qualifier, playersPart.JoinToClassyString() );

                    if( offset + playersPart.Length < visiblePlayers.Length ) {
                        player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Players {3}{1}",
                                        offset + 1, offset + playersPart.Length,
                                        visiblePlayers.Length,
                                        (worldName == null ? "" : worldName + " ") );
                    } else {
                        player.Message( "Showing players {0}-{1} (out of {2}).",
                                        offset + 1, offset + playersPart.Length,
                                        visiblePlayers.Length );
                    }
                }
            } else {
                player.Message( "There are no players {0}", qualifier );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:69,代码来源:InfoCommands.cs

示例5: GenHandler

        static void GenHandler( Player player, CommandReader cmd ) {
            World playerWorld = player.World;
            World world = null;
            string fileName = null;
            int mapWidth,
                mapLength,
                mapHeight;

            // make sure the player has generator parameters set
            MapGeneratorParameters genParams = player.GenParams;
            if( genParams == null ) {
                player.Message( "No gen parameters set. Use &H/SetGen&S to configure map generation." );
                return;
            }

            if( cmd.HasNext ) {
                // Something's given, assume that it's map dimensions.
                if( !(cmd.NextInt( out mapWidth ) && cmd.NextInt( out mapLength ) && cmd.NextInt( out mapHeight )) ) {
                    CdGen.PrintUsage( player );
                    return;
                }

            } else if( playerWorld != null ) {
                // Nothing is given. Assume that we're replacing the current world.
                // Use dimensions of the currently-loaded map.
                Map oldMap = playerWorld.LoadMap();
                mapWidth = oldMap.Width;
                mapLength = oldMap.Length;
                mapHeight = oldMap.Height;
                world = playerWorld;

            } else {
                player.Message( "When used from console, /Gen requires map dimensions." );
                CdGen.PrintUsage( player );
                return;
            }

            // Check map dimensions and volume
            const string dimensionRecommendation = "Dimensions must be between 16 and 2047. " +
                                                   "Recommended values: 16, 32, 64, 128, 256, 512, and 1024.";
            if( !Map.IsValidDimension( mapWidth ) ) {
                player.Message( "Cannot make map with width {0}. {1}", mapWidth, dimensionRecommendation );
                return;
            } else if( !Map.IsValidDimension( mapLength ) ) {
                player.Message( "Cannot make map with length {0}. {1}", mapLength, dimensionRecommendation );
                return;
            } else if( !Map.IsValidDimension( mapHeight ) ) {
                player.Message( "Cannot make map with height {0}. {1}", mapHeight, dimensionRecommendation );
                return;
            }
            long volume = (long)mapWidth*mapLength*mapHeight;
            if( volume > Int32.MaxValue ) {
                player.Message( "Map volume may not exceed {0}", Int32.MaxValue );
                return;
            }

            // Print dimension warning, if applicable.
            if( !cmd.IsConfirmed && // Only print once -- before confirmation is given.
                (!Map.IsRecommendedDimension( mapWidth ) || !Map.IsRecommendedDimension( mapLength ) ||
                 mapHeight%16 != 0) ) {
                player.Message( "&WThe map will have non-standard dimensions. " +
                                "You may see glitched blocks or visual artifacts. " +
                                "The only recommended map dimensions are: 16, 32, 64, 128, 256, 512, and 1024." );
            }

            // See what else the player has given us...
            string givenName = cmd.Next();
            if( givenName == null ) {
                // No name given. Assume that we're replacing the current world.
                if( playerWorld != null ) {
                    world = playerWorld;
                    if( !cmd.IsConfirmed ) {
                        Logger.Log( LogType.UserActivity,
                                    "Gen: Asked {0} to confirm replacing the map of world {1} (\"this map\")",
                                    player.Name,
                                    playerWorld.Name );
                        player.Confirm( cmd, "Gen: Replace THIS MAP with a generated one ({0})?", genParams );
                        return;
                    }

                } else {
                    player.Message( "When used from console, /Gen requires a world name or map file name." );
                    CdGen.PrintUsage( player );
                    return;
                }

            } else {
                // Either a world name or a filename was given. Check worlds first.
                World existingWorld = WorldManager.FindWorldExact( givenName );

                if( existingWorld != null ) {
                    // A matching world name found. Assume that we're replacing it.
                    if( !cmd.IsConfirmed ) {
                        Logger.Log( LogType.UserActivity,
                                    "Gen: Asked {0} to confirm replacing the map of world {1}",
                                    player.Name,
                                    existingWorld.Name );
                        player.Confirm( cmd,
                                        "Gen: Replace the map of world {0}&S with a generated one ({1})?",
                                        existingWorld.ClassyName,
//.........这里部分代码省略.........
开发者ID:fragmer,项目名称:fCraft,代码行数:101,代码来源:WorldCommands.cs

示例6: TeleportPHandler

 static void TeleportPHandler(Player player, CommandReader cmd)
 {
     int x, y, z;
     int rot = player.Position.R;
     int lot = player.Position.L;
     
     if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z)) {
         if (cmd.NextInt(out rot) && cmd.NextInt(out lot)) {
             if (rot < 0 || rot > 255) {
                 player.Message("R must be inbetween 0 and 255, using player R");
                 rot = player.Position.R;
             }
             if (lot < 0 || lot > 255) {
                 player.Message("L must be inbetween 0 and 255, using player L");
                 lot = player.Position.L;
             }
         }
         
         if (x < short.MinValue || x > short.MaxValue || y < short.MinValue ||
             y > short.MaxValue || z < short.MinValue || z > short.MaxValue) {
             player.Message("Coordinates are outside the valid range!");
         } else {
             if (player.World != null) {
                 player.LastWorld = player.World;
                 player.LastPosition = player.Position;
             }
             player.TeleportTo(new Position((short)x, (short)y, (short)z, 
                                            (byte)rot, (byte)lot));
         }
     } else {
         CdTeleportP.PrintUsage(player);
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:33,代码来源:ModerationCommands.cs

示例7: GlobalBlockListHandler

 static void GlobalBlockListHandler(Player player, CommandReader cmd) {
     int offset = 0, index = 0, count = 0;
     cmd.NextInt( out offset );
     BlockDefinition[] defs = BlockDefinition.GlobalDefinitions;
     for( int i = 0; i < defs.Length; i++ ) {
         BlockDefinition def = defs[i];
         if (def == null) continue;
         
         if (index >= offset) {
             count++;
             player.Message("&sCustom block &h{0} &shas name &h{1}", def.BlockID, def.Name);
             
             if(count >= 8) {
                 player.Message("To see the next set of global definitions, " +
                                "type /gb list {0}", offset + 8);
                 return;
             }
         }
         index++;
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:21,代码来源:CpeCommands.cs

示例8: WorldsHandler

        static void WorldsHandler( Player player, CommandReader cmd ) {
            string param = cmd.Next();
            World[] worlds;

            string listName;
            string extraParam;
            int offset = 0;

            if( param == null || Int32.TryParse( param, out offset ) ) {
                listName = "available worlds";
                extraParam = "";
                worlds = WorldManager.Worlds.Where( player.CanSee ).ToArray();

            } else {
                switch( Char.ToLower( param[0] ) ) {
                    case 'a':
                        listName = "worlds";
                        extraParam = "all ";
                        worlds = WorldManager.Worlds;
                        break;
                    case 'h':
                        listName = "hidden worlds";
                        extraParam = "hidden ";
                        worlds = WorldManager.Worlds.Where( w => !player.CanSee( w ) ).ToArray();
                        break;
                    case 'p':
                        listName = "populated worlds";
                        extraParam = "populated ";
                        worlds = WorldManager.Worlds.Where( w => w.Players.Any( player.CanSee ) ).ToArray();
                        break;
                    case '@':
                        if( param.Length == 1 ) {
                            CdWorlds.PrintUsage( player );
                            return;
                        }
                        string rankName = param.Substring( 1 );
                        Rank rank = RankManager.FindRank( rankName );
                        if( rank == null ) {
                            player.MessageNoRank( rankName );
                            return;
                        }
                        listName = String.Format( "worlds where {0}&S+ can build", rank.ClassyName );
                        extraParam = "@" + rank.Name + " ";
                        worlds = WorldManager.Worlds.Where( w => (w.BuildSecurity.MinRank <= rank) && player.CanSee( w ) )
                                                    .ToArray();
                        break;
                    default:
                        CdWorlds.PrintUsage( player );
                        return;
                }
                if( cmd.HasNext && !cmd.NextInt( out offset ) ) {
                    CdWorlds.PrintUsage( player );
                    return;
                }
            }

            if( worlds.Length == 0 ) {
                player.Message( "There are no {0}.", listName );

            } else if( worlds.Length <= WorldNamesPerPage || player.IsSuper ) {
                player.MessagePrefixed( "&S  ", "&SThere are {0} {1}: {2}",
                                        worlds.Length, listName, worlds.JoinToClassyString() );

            } else {
                if( offset >= worlds.Length ) {
                    offset = Math.Max( 0, worlds.Length - WorldNamesPerPage );
                }
                World[] worldsPart = worlds.Skip( offset ).Take( WorldNamesPerPage ).ToArray();
                player.MessagePrefixed( "&S   ", "&S{0}: {1}",
                                        listName.UppercaseFirst(), worldsPart.JoinToClassyString() );

                if( offset + worldsPart.Length < worlds.Length ) {
                    player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Worlds {3}{1}",
                                    offset + 1, offset + worldsPart.Length, worlds.Length, extraParam );
                } else {
                    player.Message( "Showing worlds {0}-{1} (out of {2}).",
                                    offset + 1, offset + worldsPart.Length, worlds.Length );
                }
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:80,代码来源:WorldCommands.cs

示例9: SwearHandler

 private static void SwearHandler(Player player, CommandReader cmd) {
     string param = cmd.Next();
     if (param == null) {
         CdSwear.PrintUsage(player);
         return;
     }
     switch (param.ToLower()) {
         case "r":
         case "d":
         case "remove":
         case "delete":
             int fId;
             bool removed = false;
             Filter fRemove = null;
             if (cmd.NextInt(out fId)) {
                 foreach (Filter f in Chat.Filters) {
                     if (f.Id == fId) {
                         Server.Message("&Y[Filters] {0}&Y removed the filter \"{1}\" -> \"{2}\"",
                             player.ClassyName, f.Word, f.Replacement);
                         fRemove = f;
                         removed = true;
                     }
                 }
                 if (fRemove != null) {
                     fRemove.removeFilter();
                 }
                 if (!removed) {
                     player.Message("Given filter (#{0}) does not exist.", fId);
                 }
             } else {
                 CdSwear.PrintUsage(player);
             }
             break;
         case "a":
         case "add":
         case "create":
             Filter fCreate = new Filter();
             if (player.Info.IsMuted) {
                 player.MessageMuted();
                 return;
             }
             string word = cmd.Next();
             string replacement = cmd.NextAll();
             if ("".Equals(word) || "".Equals(replacement)) {
                 CdSwear.PrintUsage(player);
                 break;
             }
             bool exists = false;
             foreach (Filter f in Chat.Filters) {
                 if (f.Word.ToLower().Equals(word.ToLower())) {
                     exists = true;
                 }
             }
             if (!exists) {
                 Server.Message("&Y[Filters] \"{0}\" is now replaced by \"{1}\"", word, replacement);
                 fCreate.addFilter(getNewFilterId(), word, replacement);
             } else {
                 player.Message("A filter with that world already exists!");
             }
             break;
         default:
             CdSwear.PrintUsage(player);
             break;
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:65,代码来源:ChatCommands.cs

示例10: CheckBlockId

 static bool CheckBlockId(Player player, CommandReader cmd, out int blockId) {
     if (!cmd.HasNext) {
         blockId = 0;
         player.Message("You most provide a block ID argument.");
         return false;
     }
     if (!cmd.NextInt(out blockId)) {
         player.Message("Provided block id is not a number.");
         return false;
     }           
     if (blockId <= 65 || blockId >= 255) {
         player.Message("Block id must be between 65-254");
         return false;
     }
     return true;
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:16,代码来源:CpeCommands.cs

示例11: TimerHandler

        static void TimerHandler(Player player, CommandReader cmd)
        {
            string param = cmd.Next();

            // List timers
            if (param == null)
            {
                ChatTimer[] list = ChatTimer.TimerList.OrderBy(timer => timer.TimeLeft).ToArray();
                if (list.Length == 0)
                {
                    player.Message("No timers running.");
                }
                else
                {
                    player.Message("There are {0} timers running:", list.Length);
                    foreach (ChatTimer timer in list)
                    {
                        if (timer.Message.Equals(""))
                        {
                            player.Message("  #{0} \"&7*CountDown*&s\" (started by {2}, {3} left)",
                                            timer.ID, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString());
                        }
                        else
                        {
                            player.Message("  #{0} \"{1}&s\" (started by {2}, {3} left)",
                                            timer.ID, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString());
                        }
                    }
                }
                return;
            }

            // Abort a timer
            if (param.Equals("abort", StringComparison.OrdinalIgnoreCase))
            {
                int timerId;
                if (cmd.NextInt(out timerId))
                {
                    ChatTimer timer = ChatTimer.FindTimerById(timerId);
                    if (timer == null || !timer.IsRunning)
                    {
                        player.Message("Given timer (#{0}) does not exist.", timerId);
                    }
                    else
                    {
                        timer.Abort();
                        string abortMsg = "";
                        string abortircMsg = "";
                        if (timer.Message.Equals(""))
                        {
                            abortMsg = String.Format("&S{0}&S aborted a &7CountDown&S with {1} left",
                                                             player.ClassyName, timer.TimeLeft.ToMiniString());
                            abortircMsg = String.Format("\u212C&S{0}&S aborted a &7CountDown&S with {1} left",
                                                             player.ClassyName, timer.TimeLeft.ToMiniString());
                        }
                        else
                        {
                            abortMsg = String.Format("&S{0}&S aborted a &7Timer&S with {1} left: &7{2}",
                                                             player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message);
                            abortircMsg = String.Format( "\u212C&S{0}&S aborted a &7Timer&S with {1} left: \u211C{2}",
                                                             player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message);
                        }
                        Server.Players.Message(abortMsg);
                        IRC.SendChannelMessage(abortircMsg);
                    }
                }
                else
                {
                    CdTimer.PrintUsage(player);
                }
                return;
            }

            // Start a timer
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }
            if (player.DetectChatSpam()) return;
            TimeSpan duration;
            if (!param.TryParseMiniTimespan(out duration))
            {
                CdTimer.PrintUsage(player);
                return;
            }
            if (duration > DateTimeUtil.MaxTimeSpan)
            {
                player.MessageMaxTimeSpan();
                return;
            }
            if (duration < ChatTimer.MinDuration)
            {
                player.Message("Timer: Must be at least 1 second.");
                return;
            }

            string sayMessage;
            string ircMessage;
            string message = cmd.NextAll();
//.........这里部分代码省略.........
开发者ID:Magi1053,项目名称:ProCraft,代码行数:101,代码来源:ChatCommands.cs

示例12: ReportsHandler

        private static void ReportsHandler(Player player, CommandReader cmd) {
            string param = cmd.Next() ?? "n/a";
            int reportId;
            // List Reports
            switch (param.ToLower()) {
                case "abort":
                case "r":
                case "d":
                case "remove":
                case "delete":
                    bool removed = false;
                    Report rRemove = null;
                    if (cmd.NextInt(out reportId)) {
                        foreach (Report r in Chat.Reports)
                            if (r.Id == reportId) {
                                player.Message("  #{0} has been removed", r.Id);
                                rRemove = r;
                                removed = true;
                            }
                        if (rRemove != null) {
                            rRemove.removeFilter();
                        }
                        if (!removed) {
                            player.Message("Given Report (#{0}) does not exist.", reportId);
                        }

                    } else {
                        CdReports.PrintUsage(player);
                    }
                    break;
                case "read":
				case "open":
				case "view":
                    bool read = false;
                    if (cmd.NextInt(out reportId)) {
                        foreach (Report r in Chat.Reports) {
                            if (r.Id == reportId) {
                                player.Message(
                                    "&s[&1Report&s] #&f{0}&n" + "  &sFrom:&f {1}&n" + "  &sDate: &7{2} at {3}&n" +
                                    "  &sMessage:&f {4}", r.Id, r.Sender, r.Datesent.ToShortDateString(),
                                    r.Datesent.ToLongTimeString(), r.Message);
                                read = true;
                            }
                        }
                        if (!read) {
                            player.Message("Given Report (#{0}) does not exist.", reportId);
                        }
                    } else {
                        CdReports.PrintUsage(player);
                    }
                    break;
                default:
                    if (Chat.Reports.Count == 0) {
                        player.Message("There are no reports.");
                    } else {
                        player.Message("There are {0} reports:", Chat.Reports.Count);
                        foreach (Report r in Chat.Reports.OrderBy(r => r.Datesent)) {
                            player.Message("&s[&1Report&s] #&f" + r.Id + " &sFrom:&f " + r.Sender);
                        }
                    }
                    break;
            }
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:63,代码来源:ChatCommands.cs

示例13: RollHandler

        static void RollHandler(Player player, CommandReader cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }
            if (player.Info.TimeSinceLastServerMessage.TotalSeconds < 5) {
                player.Info.getLeftOverTime(5, cmd);
                return;
            }

            if (player.DetectChatSpam()) return;

            Random rand = new Random();
            int n1;
            int min, max;
            if (cmd.NextInt(out n1))
            {
                int n2;
                if (!cmd.NextInt(out n2))
                {
                    n2 = 1;
                }
                min = Math.Min(n1, n2);
                max = Math.Max(n1, n2);
            }
            else
            {
                min = 1;
                max = 100;
            }

            int num = rand.Next(min, max + 1);
            Server.Message(player,
                            "{0}{1} rolled {2} ({3}...{4})",
                            player.ClassyName, Color.Silver, num, min, max);            
            player.Message("{0}You rolled {1} ({2}...{3})",
                            Color.Silver, num, min, max);
            player.Info.LastServerMessageDate = DateTime.Now;
            if (min == 1 && max == 100)
            {
                if (num == 69)
                {
                    Server.BotMessage("Tehe....69");
                }
                if (num == Server.CountPlayers(false))
                {
                    Server.BotMessage("That's how many players are online :D");
                }
            }
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:52,代码来源:ChatCommands.cs

示例14: RollHandler

        static void RollHandler( Player player, CommandReader cmd ) {
            if( player.Info.IsMuted ) {
                player.MessageMuted();
                return;
            }

            if( player.DetectChatSpam() ) return;

            Random rand = new Random();
            int n1;
            int min, max;
            if( cmd.NextInt( out n1 ) ) {
                int n2;
                if( !cmd.NextInt( out n2 ) ) {
                    n2 = 1;
                }
                min = Math.Min( n1, n2 );
                max = Math.Max( n1, n2 );
            } else {
                min = 1;
                max = 100;
            }
            if( max == Int32.MaxValue - 1 ) {
                player.Message( "Roll: Given values must be between {0} and {1}",
                                Int32.MinValue, Int32.MaxValue - 1 );
                return;
            }

            int num = rand.Next( min, max + 1 );
            Server.Message( player,
                            "{0}{1} rolled {2} ({3}...{4})",
                            player.ClassyName, Color.Silver, num, min, max );
            player.Message( "{0}You rolled {1} ({2}...{3})",
                            Color.Silver, num, min, max );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:35,代码来源:ChatCommands.cs

示例15: PortalH

        private static void PortalH(Player player, CommandReader cmd) {
            try {
                string option = cmd.Next();
                if (string.IsNullOrEmpty(option)) {
                    CdPortal.PrintUsage(player);
                    return;
                }
                switch (option.ToLower()) {
                    case "create":
                    case "add":
                        if (player.Can(Permission.CreatePortals)) {
                            string addWorld = cmd.Next();
                            if (!string.IsNullOrEmpty(addWorld) && WorldManager.FindWorldExact(addWorld) != null) {
                                DrawOperation operation = new CuboidDrawOperation(player);
                                NormalBrush brush = new NormalBrush(Block.Water, Block.Water);

                                string blockTypeOrName = cmd.Next();
                                Block pblock;
                                if (blockTypeOrName != null && Map.GetBlockByName(blockTypeOrName, false, out pblock)) {
                                    if ((!validPBlocks.Contains(pblock) && pblock <= Block.StoneBrick) || (pblock == Block.Air && player.Info.Rank != RankManager.HighestRank)) {
                                        player.Message("Invalid block, choose a non-solid block");
                                        return;
                                    } else {
                                        brush = new NormalBrush(pblock, pblock);
                                    }
                                }
                                string addPortalName = cmd.Next();
                                if (string.IsNullOrEmpty(addPortalName)) {
                                    player.PortalName = null;
                                } else {
                                    if (!Portal.DoesNameExist(player.World, addPortalName)) {
                                        player.PortalName = addPortalName;
                                    } else {
                                        player.Message("A portal with name {0} already exists in this world.", addPortalName);
                                        return;
                                    }
                                }
                                World tpWorld = WorldManager.FindWorldExact(addWorld);
                                if (cmd.HasNext) {
                                    int x, y, z, rot = player.Position.R, lot = player.Position.L;
                                    if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out z)) {
                                        if (cmd.HasNext && cmd.HasNext) {
                                            if (cmd.NextInt(out rot) && cmd.NextInt(out lot)) {
                                                if (rot > 255 || rot < 0) {
                                                    player.Message("R must be inbetween 0 and 255. Set to player R");
                                                    rot = player.Position.R;
                                                }
                                                if (lot > 255 || lot < 0) {
                                                    player.Message("L must be inbetween 0 and 255. Set to player L");
                                                    lot = player.Position.L;
                                                }
                                            }
                                        }
                                        if (x < 1 || x >= 1024 || y < 1 || y >= 1024 || z < 1 || z >= 1024) {
                                            player.Message("Coordinates are outside the valid range!");
                                            return;
                                        } else {
                                            player.PortalTPPos = new Position((short)(x * 32), (short)(y * 32), (short)(z * 32), (byte)rot, (byte)lot);
                                        }
                                    } else {
                                        player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
                                    }
                                } else {
                                    player.PortalTPPos = tpWorld.map == null ? new Position(0, 0, 0) : tpWorld.map.Spawn;
                                }
                                operation.Brush = brush;
                                player.PortalWorld = addWorld;
                                player.SelectionStart(operation.ExpectedMarks, PortalCreateCallback, operation, Permission.CreatePortals);
                                player.Message("Click {0} blocks or use &H/Mark&S to mark the area of the portal.", operation.ExpectedMarks);
                            } else {
                                if (string.IsNullOrEmpty(addWorld)) {
                                    player.Message("No world specified.");
                                } else {
                                    player.MessageNoWorld(addWorld);
                                }
                            }
                        } else {
                            player.MessageNoAccess(Permission.CreatePortals);
                        }
                        break;
                    case "remove":
                    case "delete":
                        if (player.Can(Permission.CreatePortals)) {
                            string remPortalName = cmd.Next();
                            string remWString = cmd.Next();
                            World remWorld = player.World;
                            if (!string.IsNullOrEmpty(remWString)) {
                                remWorld = WorldManager.FindWorldOrPrintMatches(player, remWString);
                            }
                            if (remWorld == null) {
                                return;
                            }
                            if (string.IsNullOrEmpty(remPortalName)) {
                                player.Message("No portal name specified.");
                            } else {
                                if (remWorld.Portals != null && remWorld.Portals.Count > 0) {
                                    bool found = false;
                                    Portal portalFound = null;
                                    lock (remWorld.Portals.SyncRoot) {
                                        foreach (Portal portal in remWorld.Portals) {
//.........这里部分代码省略.........
开发者ID:Magi1053,项目名称:ProCraft,代码行数:101,代码来源:WorldCommands.cs


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