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


C# Player.MessageNoRank方法代码示例

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


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

示例1: SetInfoHandler

        static void SetInfoHandler( Player player, CommandReader cmd ) {
            string targetName = cmd.Next();
            string propertyName = cmd.Next();
            string valName = cmd.NextAll();

            if( targetName == null || propertyName == null ) {
                CdSetInfo.PrintUsage( player );
                return;
            }

            PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetName, SearchOptions.IncludeSelf );
            if( info == null ) return;

            switch( propertyName.ToLower() ) {
                case "timeskicked":
                case "tk":
                    int oldTimesKicked = info.TimesKicked;
                    if( ValidateInt( valName, 0, 9999 ) ) {
                        info.TimesKicked = Int32.Parse( valName );
                        player.Message( "SetInfo: TimesKicked for {0}&S changed from {1} to {2}",
                                        info.ClassyName,
                                        oldTimesKicked,
                                        info.TimesKicked );
                        break;
                    } else {
                        player.Message( "SetInfo: TimesKicked value out of range (acceptable: 0-9999)" );
                        return;
                    }

                case "previousrank":
                case "pr":
                    Rank newPreviousRank;
                    if( valName.Length > 0 ) {
                        newPreviousRank = RankManager.FindRank( valName );
                        if( newPreviousRank == null ) {
                            player.MessageNoRank( valName );
                            return;
                        }
                    } else {
                        newPreviousRank = null;
                    }

                    Rank oldPreviousRank = info.PreviousRank;

                    if( newPreviousRank == null && oldPreviousRank == null ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S is not set.",
                                        info.ClassyName );
                        return;
                    } else if( newPreviousRank == oldPreviousRank ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S is already set to {1}",
                                        info.ClassyName,
                                        newPreviousRank.ClassyName );
                        return;
                    }
                    info.PreviousRank = newPreviousRank;

                    if( oldPreviousRank == null ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S set to {1}&",
                                        info.ClassyName,
                                        newPreviousRank.ClassyName );
                    } else if( newPreviousRank == null ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S was reset (was {1}&S)",
                                        info.ClassyName,
                                        oldPreviousRank.ClassyName );
                    } else {
                        player.Message( "SetInfo: PreviousRank for {0}&S changed from {1}&S to {2}",
                                        info.ClassyName,
                                        oldPreviousRank.ClassyName,
                                        newPreviousRank.ClassyName );
                    }
                    break;

                case "totaltime":
                case "tt":
                    TimeSpan newTotalTime;
                    TimeSpan oldTotalTime = info.TotalTime;
                    if( valName.TryParseMiniTimeSpan( out newTotalTime ) ) {
                        if( newTotalTime > DateTimeUtil.MaxTimeSpan ) {
                            player.MessageMaxTimeSpan();
                            return;
                        }
                        info.TotalTime = newTotalTime;
                        player.Message( "SetInfo: TotalTime for {0}&S changed from {1} ({2}) to {3} ({4})",
                                        info.ClassyName,
                                        oldTotalTime.ToMiniString(),
                                        oldTotalTime.ToCompactString(),
                                        info.TotalTime.ToMiniString(),
                                        info.TotalTime.ToCompactString() );
                        break;
                    } else {
                        player.Message( "SetInfo: Could not parse value given for TotalTime." );
                        return;
                    }

                case "rankchangetype":
                case "rct":
                    RankChangeType oldType = info.RankChangeType;
                    RankChangeType newType;
                    if(!EnumUtil.TryParse(valName, out newType, true)){
                        player.Message( "SetInfo: Could not parse RankChangeType. Allowed values: {0}",
//.........这里部分代码省略.........
开发者ID:fragmer,项目名称:fCraft,代码行数:101,代码来源:MaintenanceCommands.cs

示例2: SetInfoHandler

        static void SetInfoHandler( Player player, Command cmd )
        {
            string targetName = cmd.Next();
            string propertyName = cmd.Next();
            string valName = cmd.NextAll();

            if( targetName == null || propertyName == null ) {
                CdSetInfo.PrintUsage( player );
                return;
            }

            PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetName );
            if( info == null ) return;

            switch( propertyName.ToLower() ) {
                case "timeskicked":
                    int oldTimesKicked = info.TimesKicked;
                    if( ValidateInt( valName, 0, 9999 ) ) {
                        info.TimesKicked = Int32.Parse( valName );
                        player.Message( "SetInfo: TimesKicked for {0}&S changed from {1} to {2}",
                                        info.ClassyName,
                                        oldTimesKicked,
                                        info.TimesKicked );
                    } else {
                        player.Message( "SetInfo: TimesKicked value acceptible (Acceptible value range: 0-9999)" );
                    }
                    return;

                case "previousrank":
                    Rank newPreviousRank;
                    if( valName.Length > 0 ) {
                        newPreviousRank = RankManager.FindRank( valName );
                        if( newPreviousRank == null ) {
                            player.MessageNoRank( valName );
                            return;
                        }
                    } else {
                        newPreviousRank = null;
                    }

                    Rank oldPreviousRank = info.PreviousRank;

                    if( newPreviousRank == oldPreviousRank ) {
                        if( newPreviousRank == null ) {
                            player.Message( "SetInfo: PreviousRank for {0}&S is not set.",
                                            info.ClassyName );
                        } else {
                            player.Message( "SetInfo: PreviousRank for {0}&S is already set to {1}",
                                            info.ClassyName,
                                            newPreviousRank.ClassyName );
                        }
                        return;
                    }

                    if( oldPreviousRank == null ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S set to {1}&",
                                        info.ClassyName,
                                        newPreviousRank.ClassyName );
                    } else if( newPreviousRank == null ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S was reset (was {1}&S)",
                                        info.ClassyName,
                                        oldPreviousRank.ClassyName );
                    } else {
                        player.Message( "SetInfo: PreviousRank for {0}&S changed from {1}&S to {2}",
                                        info.ClassyName,
                                        oldPreviousRank.ClassyName,
                                        newPreviousRank.ClassyName );
                    }
                    return;

                case "totaltime":
                    TimeSpan newTotalTime;
                    TimeSpan oldTotalTime = info.TotalTime;
                    if( valName.TryParseMiniTimespan( out newTotalTime ) ) {
                        info.TotalTime = newTotalTime;
                        player.Message( "SetInfo: TotalTime for {0}&S changed from {1} ({2}) to {3} ({4})",
                                        info.ClassyName,
                                        oldTotalTime.ToMiniString(),
                                        oldTotalTime.ToCompactString(),
                                        info.TotalTime.ToMiniString(),
                                        info.TotalTime.ToCompactString() );
                    } else {
                        player.Message( "SetInfo: Could not parse value given for TotalTime." );
                    }
                    return;

                case "rankchangetype":
                    RankChangeType oldType = info.RankChangeType;
                    try {
                        info.RankChangeType = (RankChangeType)Enum.Parse( typeof( RankChangeType ), valName, true );
                    } catch( ArgumentException ) {
                        player.Message( "SetInfo: Could not parse RankChangeType. Allowed values: {0}",
                                        String.Join( ", ", Enum.GetNames( typeof( RankChangeType ) ) ) );
                        return;
                    }
                    player.Message( "SetInfo: RankChangeType for {0}&S changed from {1} to {2}",
                                    info.ClassyName,
                                    oldType,
                                    info.RankChangeType );
                    return;
//.........这里部分代码省略.........
开发者ID:Blingpancakeman,项目名称:800craft,代码行数:101,代码来源:MaintenanceCommands.cs

示例3: ImportRanks

        static void ImportRanks( Player player, Command cmd )
        {
            string serverName = cmd.Next();
            string fileName = cmd.Next();
            string rankName = cmd.Next();
            bool silent = (cmd.Next() != null);

            // Make sure all parameters are specified
            if( serverName == null || fileName == null || rankName == null ) {
                CdImport.PrintUsage( player );
                return;
            }

            // Check if file exists
            if( !File.Exists( fileName ) ) {
                player.Message( "File not found: {0}", fileName );
                return;
            }

            Rank targetRank = RankManager.FindRank( rankName );
            if( targetRank == null ) {
                player.MessageNoRank( rankName );
                return;
            }

            string[] names;

            switch( serverName.ToLower() ) {
                case "mcsharp":
                case "mczall":
                case "mclawl":
                    try {
                        names = File.ReadAllLines( fileName );
                    } catch( Exception ex ) {
                        Logger.Log( LogType.Error,
                                    "Could not open \"{0}\" to import ranks: {1}",
                                    fileName, ex );
                        return;
                    }
                    break;
                default:
                    player.Message( "fCraft does not support importing from {0}", serverName );
                    return;
            }

            if( !cmd.IsConfirmed ) {
                player.Confirm( cmd, "You are about to import {0} player ranks.", names.Length );
                return;
            }

            string reason = "(Import from " + serverName + ")";
            foreach( string name in names ) {
                PlayerInfo info = PlayerDB.FindPlayerInfoExact( name ) ??
                                  PlayerDB.AddFakeEntry( name, RankChangeType.Promoted );
                try {
                    info.ChangeRank( player, targetRank, reason, !silent, true, false );
                } catch( PlayerOpException ex ) {
                    player.Message( ex.MessageColored );
                }
            }

            PlayerDB.Save();
        }
开发者ID:Blingpancakeman,项目名称:800craft,代码行数:63,代码来源:MaintenanceCommands.cs

示例4: BringAllHandler

        static void BringAllHandler( Player player, CommandReader cmd ) {
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );

            List<World> targetWorlds = new List<World>();
            List<Rank> targetRanks = new List<Rank>();
            bool allWorlds = false;
            bool allRanks = true;

            // Parse the list of worlds and ranks
            string arg;
            while( (arg = cmd.Next()) != null ) {
                if( arg.StartsWith( "@" ) ) {
                    Rank rank = RankManager.FindRank( arg.Substring( 1 ) );
                    if( rank == null ) {
                        player.MessageNoRank( arg.Substring( 1 ) );
                        return;
                    } else {
                        if( player.Can( Permission.Bring, rank ) ) {
                            targetRanks.Add( rank );
                        } else {
                            player.Message( "&WYou are not allowed to bring players of rank {0}",
                                            rank.ClassyName );
                        }
                        allRanks = false;
                    }
                } else if( arg == "*" ) {
                    allWorlds = true;
                } else {
                    World world = WorldManager.FindWorldOrPrintMatches( player, arg );
                    if( world == null ) return;
                    targetWorlds.Add( world );
                }
            }

            // If no worlds were specified, use player's current world
            if( !allWorlds && targetWorlds.Count == 0 ) {
                targetWorlds.Add( player.World );
            }

            // Apply all the rank and world options
            HashSet<Player> targetPlayers;
            if( allRanks && allWorlds ) {
                targetPlayers = new HashSet<Player>( Server.Players );
            } else if( allWorlds ) {
                targetPlayers = new HashSet<Player>();
                foreach( Rank rank in targetRanks ) {
                    foreach( Player rankPlayer in Server.Players.Ranked( rank ) ) {
                        targetPlayers.Add( rankPlayer );
                    }
                }
            } else if( allRanks ) {
                targetPlayers = new HashSet<Player>();
                foreach( World world in targetWorlds ) {
                    foreach( Player worldPlayer in world.Players ) {
                        targetPlayers.Add( worldPlayer );
                    }
                }
            } else {
                targetPlayers = new HashSet<Player>();
                foreach( Rank rank in targetRanks ) {
                    foreach( World world in targetWorlds ) {
                        foreach( Player rankWorldPlayer in world.Players.Ranked( rank ) ) {
                            targetPlayers.Add( rankWorldPlayer );
                        }
                    }
                }
            }

            Rank bringLimit = player.Info.Rank.GetLimit( Permission.Bring );

            // Remove the player him/herself
            targetPlayers.Remove( player );

            int count = 0;


            // Actually bring all the players
            foreach( Player targetPlayer in targetPlayers.CanBeSeen( player )
                                                         .RankedAtMost( bringLimit ) ) {
                if( targetPlayer.World == playerWorld ) {
                    // teleport within the same world
                    targetPlayer.TeleportTo( player.Position );
                    targetPlayer.Position = player.Position;
                    if( targetPlayer.Info.IsFrozen ) {
                        targetPlayer.Position = player.Position;
                    }

                } else {
                    // teleport to a different world
                    BringPlayerToWorld( player, targetPlayer, playerWorld, false, true );
                }
                count++;
            }

            // Check if there's anyone to bring
            if( count == 0 ) {
                player.Message( "No players to bring!" );
            } else {
                player.Message( "Bringing {0} players...", count );
//.........这里部分代码省略.........
开发者ID:fragmer,项目名称:fCraft,代码行数:101,代码来源:ModerationCommands.cs

示例5: RankInfoHandler

        // Shows general information about a particular rank.
        static void RankInfoHandler( Player player, CommandReader cmd ) {
            Rank rank;

            string rankName = cmd.Next();
            if( cmd.HasNext ) {
                CdRankInfo.PrintUsage( player );
                return;
            }

            if( rankName == null ) {
                rank = player.Info.Rank;
            } else {
                rank = RankManager.FindRank( rankName );
                if( rank == null ) {
                    player.MessageNoRank( rankName );
                    return;
                }
            }

            List<Permission> permissions = new List<Permission>();
            for( int i = 0; i < rank.Permissions.Length; i++ ) {
                if( rank.Permissions[i] ) {
                    permissions.Add( (Permission)i );
                }
            }

            Permission[] sortedPermissionNames =
                permissions.OrderBy( s => s.ToString(), StringComparer.OrdinalIgnoreCase ).ToArray();
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat( "Players of rank {0}&S can: ", rank.ClassyName );
                bool first = true;
                for( int i = 0; i < sortedPermissionNames.Length; i++ ) {
                    Permission p = sortedPermissionNames[i];
                    if( !first ) sb.Append( ',' ).Append( ' ' );
                    Rank permissionLimit = rank.PermissionLimits[(int)p];
                    sb.Append( p );
                    if( permissionLimit != null ) {
                        sb.AppendFormat( "({0}&S)", permissionLimit.ClassyName );
                    }
                    first = false;
                }
                player.Message( sb.ToString() );
            }

            if( rank.Can( Permission.Draw ) ) {
                StringBuilder sb = new StringBuilder();
                if( rank.DrawLimit > 0 ) {
                    sb.AppendFormat( "Draw limit: {0} blocks.", rank.DrawLimit );
                } else {
                    sb.AppendFormat( "Draw limit: None (unlimited)." );
                }
                if( rank.Can( Permission.CopyAndPaste ) ) {
                    sb.AppendFormat( " Copy/paste slots: {0}", rank.CopySlots );
                }
                player.Message( sb.ToString() );
            }

            if( rank.IdleKickTimer > 0 ) {
                player.Message( "Idle kick after {0}", TimeSpan.FromMinutes( rank.IdleKickTimer ).ToMiniString() );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:63,代码来源:InfoCommands.cs

示例6: WorldsHandler

        static void WorldsHandler(Player player, Command 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(w => !w.IsRealm).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 'r':
                        listName = "Available Realms";
                        extraParam = "realms";
                        worlds = WorldManager.Worlds.Where(w => w.IsRealm).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:Rhinovex,项目名称:LegendCraft,代码行数:101,代码来源:WorldCommands.cs

示例7: ZoneEditHandler

        static void ZoneEditHandler( Player player, Command cmd )
        {
            bool changesWereMade = false;
            string zoneName = cmd.Next();
            if( zoneName == null ) {
                player.Message( "No zone name specified. See &H/Help ZEdit" );
                return;
            }

            Zone zone = player.WorldMap.Zones.Find( zoneName );
            if( zone == null ) {
                player.MessageNoZone( zoneName );
                return;
            }

            string name;
            while( (name = cmd.Next()) != null ) {
                if( name.Length < 2 ) continue;

                if( name.StartsWith( "+" ) ) {
                    PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, name.Substring( 1 ) );
                    if( info == null ) return;

                    // prevent players from whitelisting themselves to bypass protection
                    if( !player.Info.Rank.AllowSecurityCircumvention && player.Info == info ) {
                        if( !zone.Controller.Check( info ) ) {
                            player.Message( "You must be {0}+&S to add yourself to this zone's whitelist.",
                                            zone.Controller.MinRank.ClassyName );
                            continue;
                        }
                    }

                    switch( zone.Controller.Include( info ) ) {
                        case PermissionOverride.Deny:
                            player.Message( "{0}&S is no longer excluded from zone {1}",
                                            info.ClassyName, zone.ClassyName );
                            changesWereMade = true;
                            break;
                        case PermissionOverride.None:
                            player.Message( "{0}&S is now included in zone {1}",
                                            info.ClassyName, zone.ClassyName );
                            changesWereMade = true;
                            break;
                        case PermissionOverride.Allow:
                            player.Message( "{0}&S is already included in zone {1}",
                                            info.ClassyName, zone.ClassyName );
                            break;
                    }

                } else if( name.StartsWith( "-" ) ) {
                    PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, name.Substring( 1 ) );
                    if( info == null ) return;

                    switch( zone.Controller.Exclude( info ) ) {
                        case PermissionOverride.Deny:
                            player.Message( "{0}&S is already excluded from zone {1}",
                                            info.ClassyName, zone.ClassyName );
                            break;
                        case PermissionOverride.None:
                            player.Message( "{0}&S is now excluded from zone {1}",
                                            info.ClassyName, zone.ClassyName );
                            changesWereMade = true;
                            break;
                        case PermissionOverride.Allow:
                            player.Message( "{0}&S is no longer included in zone {1}",
                                            info.ClassyName, zone.ClassyName );
                            changesWereMade = true;
                            break;
                    }

                } else {
                    Rank minRank = RankManager.FindRank( name );

                    if( minRank != null ) {
                        // prevent players from lowering rank so bypass protection
                        if( !player.Info.Rank.AllowSecurityCircumvention &&
                            zone.Controller.MinRank > player.Info.Rank && minRank <= player.Info.Rank ) {
                            player.Message( "You are not allowed to lower the zone's rank." );
                            continue;
                        }

                        if( zone.Controller.MinRank != minRank ) {
                            zone.Controller.MinRank = minRank;
                            player.Message( "Permission for zone \"{0}\" changed to {1}+",
                                            zone.Name,
                                            minRank.ClassyName );
                            changesWereMade = true;
                        }
                    } else {
                        player.MessageNoRank( name );
                    }
                }

                if( changesWereMade ) {
                    zone.Edit( player.Info );
                } else {
                    player.Message( "No changes were made to the zone." );
                }
            }
        }
开发者ID:Desertive,项目名称:800craft,代码行数:100,代码来源:ZoneCommands.cs

示例8: ListStaffHandler

        static void ListStaffHandler(Player player, CommandReader cmd)
        {
            Rank ranktarget;
            if (cmd.HasNext)
            {
                string rankName = cmd.Next();
                ranktarget = RankManager.FindRank( rankName );
                if (ranktarget == null)
                {
                    player.MessageNoRank(rankName);
                    return;
                }
            }
            else ranktarget = null;

            PlayerInfo[] infos;

            if (ranktarget == null)
            {
                player.Message("&sBelow is a list of ALL staff members.");
                foreach (Rank rank in RankManager.Ranks)
                {
                    if (rank.IsStaff)
                    {
                        infos = PlayerDB.PlayerInfoList
                                        .Where(info => info.Rank == rank)
                                        .ToArray();
                        if (infos != null && rank.PlayerCount > 0)
                        {
                            Array.Sort(infos, new PlayerInfoComparer(player));
                            IClassy[] itemsEnumerated = infos;
                            string nameList = itemsEnumerated.Take( 15 ).JoinToString( "&s, ", p => p.ClassyName );
                            if (rank.PlayerCount > 15) {
                                player.Message( " {0} &s(&f{1}&s): {2}{3} &s{4} more", rank.ClassyName, rank.PlayerCount, rank.Color, nameList, (rank.PlayerCount - 15) );
                            } else {
                                player.Message( " {0} &s(&f{1}&s): {2}{3}", rank.ClassyName, rank.PlayerCount, rank.Color, nameList );
                            }
                        }
                    }
                }
            }
            else
            {
                player.Message("&sBelow is a list of ALL staff members of rank '" + ranktarget.ClassyName + "&s':");
                infos = PlayerDB.PlayerInfoList
                                .Where(info => info.Rank == ranktarget)
                                .ToArray();
                if (infos != null)
                {
                    Array.Sort(infos, new PlayerInfoComparer(player));
                    IClassy[] itemsEnumerated = infos;
                    string nameList = itemsEnumerated.Take(30).JoinToString(", ", p => p.ClassyName);
                    if (ranktarget.PlayerCount > 15) {
                        player.Message( " {0} &s(&f{1}&s): {2}{3} &s{4} more", ranktarget.ClassyName, ranktarget.PlayerCount, ranktarget.Color, nameList, (ranktarget.PlayerCount - 30) );
                    } else {
                        player.Message( " {0} &s(&f{1}&s): {2}{3}", ranktarget.ClassyName, ranktarget.PlayerCount, ranktarget.Color, nameList );
                    }
                }
            }
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:60,代码来源:InfoCommands.cs

示例9: MassRankHandler

        static void MassRankHandler( Player player, CommandReader cmd ) {
            string fromRankName = cmd.Next();
            string toRankName = cmd.Next();
            string reason = cmd.NextAll();
            if( fromRankName == null || toRankName == null ) {
                CdMassRank.PrintUsage( player );
                return;
            }

            Rank fromRank = RankManager.FindRank( fromRankName );
            if( fromRank == null ) {
                player.MessageNoRank( fromRankName );
                return;
            }

            Rank toRank = RankManager.FindRank( toRankName );
            if( toRank == null ) {
                player.MessageNoRank( toRankName );
                return;
            }

            if( fromRank == toRank ) {
                player.Message( "Ranks must be different" );
                return;
            }

            int playerCount = fromRank.PlayerCount;
            string verb = (fromRank > toRank ? "demot" : "promot");

            if( !cmd.IsConfirmed ) {
                Logger.Log( LogType.UserActivity,
                            "MassRank: Asked {0} to confirm {1}ion of {2} players.",
                            player.Name, verb, playerCount );
                player.Confirm( cmd, "{0}e {1} players?", verb.UppercaseFirst(), playerCount );
                return;
            }

            player.Message( "MassRank: {0}ing {1} players...",
                            verb, playerCount );

            int affected = PlayerDB.MassRankChange( player, fromRank, toRank, reason );
            player.Message( "MassRank: done, {0} records affected.", affected );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:43,代码来源:MaintenanceCommands.cs

示例10: LPRHandler

 static void LPRHandler(Player player, CommandReader cmd)
 {
     string name = cmd.Next();
     PlayerInfo[] infos;
     Rank rank = RankManager.FindRank(player.Info.Rank.Name);
     if (name != null)
     {
         rank = RankManager.FindRank(name);
         if (rank == null)
         {
             player.MessageNoRank(name);
             return;
         }
     }
     infos = PlayerDB.PlayerInfoList.Where(info => info.PreviousRank == rank).OrderBy(c => c.TimeSinceRankChange).ToArray();
     int offset;
     if (!cmd.NextInt(out offset)) offset = 0;            
     if (offset >= infos.Count())
     {
         offset = Math.Max(0, infos.Count() - PlayersPerPage);
     }
     var playersPart = infos.Skip(offset).Take(10).ToArray();
     player.MessagePrefixed("&S   ", "&SPlayers who previously had rank ({1}&s): {0}", playersPart.JoinToString((r => String.Format("&n{0}&S (Had current rank ({2}&s) for: {1})", r.ClassyName, r.TimeSinceRankChange.ToMiniString(), r.Rank.ClassyName))), rank.ClassyName);
     player.Message("Showing players {0}-{1} (out of {2}).", offset + 1, offset + playersPart.Length, infos.Count());
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:25,代码来源:InfoCommands.cs

示例11: RankInfoHandler

        // Shows general information about a particular rank.
        static void RankInfoHandler( Player player, CommandReader cmd ) {
            Rank rank;

            string rankName = cmd.Next();
            if( cmd.HasNext ) {
                CdRankInfo.PrintUsage( player );
                return;
            }

            if( rankName == null ) {
                rank = player.Info.Rank;
            } else {
                rank = RankManager.FindRank( rankName );
                if( rank == null ) {
                    player.MessageNoRank( rankName );
                    return;
                }
            }

            List<Permission> permissions = new List<Permission>();
            for( int i = 0; i < rank.Permissions.Length; i++ ) {
                if( rank.Permissions[i] ) {
                    permissions.Add( (Permission)i );
                }
            }

            Permission[] sortedPermissionNames =
                permissions.OrderBy( s => s.ToString(), StringComparer.OrdinalIgnoreCase ).ToArray();
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat( "Players of rank {0}&S can: ", rank.ClassyName );
                bool first = true;
                for( int i = 0; i < sortedPermissionNames.Length; i++ ) {
                    Permission p = sortedPermissionNames[i];
                    if( !first ) sb.Append( ',' ).Append( ' ' );
                    Rank permissionLimit = rank.PermissionLimits[(int)p];
                    sb.Append( p );
                    if( permissionLimit != null ) {
                        sb.AppendFormat( "({0}&S)", permissionLimit.ClassyName );
                    }
                    first = false;
                }
                player.Message( sb.ToString() );
            }

            if( rank.Can( Permission.Draw ) ) {
                StringBuilder sb = new StringBuilder();
                if( rank.DrawLimit > 0 ) {
                    sb.AppendFormat( "Draw limit: {0} blocks.", rank.DrawLimit );
                } else {
                    sb.AppendFormat( "Draw limit: None (unlimited)." );
                }
                if( rank.Can( Permission.CopyAndPaste ) ) {
                    sb.AppendFormat( " Copy/paste slots: {0}", rank.CopySlots );
                }
                player.Message( sb.ToString() );
            }

            if( rank.IdleKickTimer > 0 ) {
                player.Message( "Idle kick after {0}", TimeSpan.FromMinutes( rank.IdleKickTimer ).ToMiniString() );
            }
            if (Directory.Exists(Paths.RankReqDirectory) && player.IsStaff) {
                string rankReqFileName = null;
                string[] sectionFiles = Directory.GetFiles(Paths.RankReqPath,rank.Name.ToLower() + ".txt", SearchOption.TopDirectoryOnly);
                for (int i = 0; i < sectionFiles.Length; i++) {
                    string sectionFullName = Path.GetFileNameWithoutExtension(sectionFiles[i]).ToLower();
                    if (rank.Name.ToLower().Equals(sectionFullName)) {
                        rankReqFileName = sectionFiles[i];
                        break;
                    }
                }
                if (rankReqFileName != null) {
                    string sectionFullName = Path.GetFileNameWithoutExtension(rankReqFileName);
                    FileInfo rankReqFile = new FileInfo(rankReqFileName);
                    try {
                        string[] ruleLines = File.ReadAllLines(rankReqFile.FullName);
                        player.Message("&RRank requirements:");
                        foreach (string ruleLine in ruleLines) {
                            if (ruleLine.Trim().Length > 0) {
                                player.Message("&R{0}", Chat.ReplaceTextKeywords(player, ruleLine));
                            }
                        }
                    } catch (Exception ex) {
                        Logger.Log(LogType.Error,
                                    "InfoCommands.PrintRankReq: An error occurred while trying to read {0}: {1}",
                                    rankReqFile.FullName, ex);
                        player.Message("&WError reading the rank requirement file.");
                    }
                }
            }
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:92,代码来源:InfoCommands.cs

示例12: MostHandler

        private static void MostHandler(Player player, CommandReader cmd) {
            string stat = cmd.Next();
            if (string.IsNullOrEmpty(stat)) {
                CdMost.PrintUsage(player);
                return;
            }
            string rankStr = cmd.Next();
            string offsetStr = cmd.Next();
            string value;
            bool noRank = false;
            int offset = 0, pad = 0;
            Rank rank = RankManager.FindRank(rankStr);
            if (string.IsNullOrEmpty(rankStr)) {
                noRank = true;
            } else {
                if (rank == null) {
                    if (!int.TryParse(rankStr, out offset)) {
                        player.MessageNoRank(rankStr);
                        return;
                    } else {
                        noRank = true;
                    }
                }
                if (offsetStr != null) {
                    if (!int.TryParse(offsetStr, out offset)) {
                        offset = 0;
                    }
                }
            }

            IEnumerable<PlayerInfo> allPlayers = PlayerDB.PlayerInfoList;
            PlayerInfo[] playersPart = allPlayers.ToArray();
            switch (stat.ToLower()) {
                case ("bans"):
                case ("banned"):
                    allPlayers = allPlayers.Where(p => p.TimesBannedOthers >= 1 && (!noRank ? (p.Rank == rank) : true)).OrderBy(c => c.TimesBannedOthers).ToArray().Reverse();
                    playersPart = allPlayers.Skip(fixOffset(offset, allPlayers.Count())).Take(10).ToArray();
                    pad = string.Format("{0:N0}", playersPart[0].TimesBannedOthers).Length;
                    player.Message("&STop Players ({0}):", stat);
                    for (int i = 0; i < playersPart.Count(); i++) {
                        value = string.Format("{0:N0}", playersPart[i].TimesBannedOthers);
                        sendMostMessage(player, value, playersPart[i], pad);
                    }
                    break;
                case ("built"):
                    allPlayers = allPlayers.Where(p => p.BlocksBuilt >= 1 && (!noRank ? (p.Rank == rank) : true)).OrderBy(c => c.BlocksBuilt).ToArray().Reverse();
                    playersPart = allPlayers.Skip(fixOffset(offset, allPlayers.Count())).Take(10).ToArray();
                    pad = string.Format("{0:N0}", playersPart[0].BlocksBuilt).Length;
                    player.Message("&STop Players ({0}):", stat);
                    for (int i = 0; i < playersPart.Count(); i++) {
                        value = string.Format("{0:N0}", playersPart[i].BlocksBuilt);
                        sendMostMessage(player, value, playersPart[i], pad);
                    }
                    break;
                case ("chat"):
                    allPlayers = allPlayers.Where(p => p.MessagesWritten >= 1 && (!noRank ? (p.Rank == rank) : true)).OrderBy(c => c.MessagesWritten).ToArray().Reverse();
                    playersPart = allPlayers.Skip(fixOffset(offset, allPlayers.Count())).Take(10).ToArray();
                    pad = string.Format("{0:N0}", playersPart[0].MessagesWritten).Length;
                    player.Message("&STop Players ({0}):", stat);
                    for (int i = 0; i < playersPart.Count(); i++) {
                        value = string.Format("{0:N0}", playersPart[i].MessagesWritten);
                        sendMostMessage(player, value, playersPart[i], pad);
                    }
                    break;
                case ("deleted"):
                    allPlayers = allPlayers.Where(p => p.BlocksDeleted >= 1 && (!noRank ? (p.Rank == rank) : true)).OrderBy(c => c.BlocksDeleted).ToArray().Reverse();
                    playersPart = allPlayers.Skip(fixOffset(offset, allPlayers.Count())).Take(10).ToArray();
                    pad = string.Format("{0:N0}", playersPart[0].BlocksDeleted).Length;
                    player.Message("&STop Players ({0}):", stat);
                    for (int i = 0; i < playersPart.Count(); i++) {
                        value = string.Format("{0:N0}", playersPart[i].BlocksDeleted);
                        sendMostMessage(player, value, playersPart[i], pad);
                    }
                    break;
                case ("demoted"):
                    allPlayers = allPlayers.Where(p => p.DemoCount >= 1 && (!noRank ? (p.Rank == rank) : true)).OrderBy(c => c.DemoCount).ToArray().Reverse();
                    playersPart = allPlayers.Skip(fixOffset(offset, allPlayers.Count())).Take(10).ToArray();
                    pad = string.Format("{0:N0}", playersPart[0].DemoCount).Length;
                    player.Message("&STop Players ({0}):", stat);
                    for (int i = 0; i < playersPart.Count(); i++) {
                        value = string.Format("{0:N0}", playersPart[i].DemoCount);
                        sendMostMessage(player, value, playersPart[i], pad);
                    }
                    break;
                case ("drawn"):
                    allPlayers = allPlayers.Where(p => p.BlocksDrawn >= 1 && (!noRank ? (p.Rank == rank) : true)).OrderBy(c => c.BlocksDrawn).ToArray().Reverse();
                    playersPart = allPlayers.Skip(fixOffset(offset, allPlayers.Count())).Take(10).ToArray();
                    pad = string.Format("{0:N0}&sK", (playersPart[0].BlocksDrawn / 1000D)).Length;
                    player.Message("&STop Players ({0}):", stat);
                    for (int i = 0; i < playersPart.Count(); i++) {
                        value = string.Format("{0:N0}&sK", (playersPart[i].BlocksDrawn / 1000D));
                        sendMostMessage(player, value, playersPart[i], pad);
                    }
                    break;
                case ("time"):
                case ("hours"):
                    allPlayers = allPlayers.Where(p => p.TotalTime.ToHours() >= 1 && (!noRank ? (p.Rank == rank) : true)).OrderBy(c => c.TotalTime.ToHours()).ToArray().Reverse();
                    playersPart = allPlayers.Skip(fixOffset(offset, allPlayers.Count())).Take(10).ToArray();
                    pad = string.Format("{0:N2}&sH", playersPart[0].TotalTime.TotalHours).Length;
                    player.Message("&STop Players ({0}):", stat);
//.........这里部分代码省略.........
开发者ID:Magi1053,项目名称:ProCraft,代码行数:101,代码来源:InfoCommands.cs

示例13: CommandsHandler

        private static void CommandsHandler(Player player, CommandReader cmd) {
            string param = cmd.Next();
            CommandDescriptor[] cd;
            CommandCategory category;
            string prefix;
            if (param == null) {
                player.Message("&sCommand Categories:");
                player.Message("&h  /cmds Building");
                player.Message("&h  /cmds Chat");
                player.Message("&h  /cmds Info");
                player.Message("&h  /cmds Maintenance");
                player.Message("&h  /cmds Moderation");
                player.Message("&h  /cmds World");
                player.Message("&h  /cmds New");
                player.Message("&h  /cmds All");
                return;
			}
			Array items = CommandManager.GetCommands(player.Info.Rank, false);
			string output = "";
            if (param.StartsWith("*") && param.EndsWith("*")) {
                foreach (CommandDescriptor item in items) {
                    if (item.Name.ToLower().Contains(param.ToLower().Trim('*'))) {
                        output += item.MinRank.Color + item.Name + "&s, ";
                    }
                }
                player.Message("&sCommands containing \"{0}\":", param.Trim('*'));
				if (output.EndsWith(", ")) {
					player.Message(output.Remove(output.Length - 2) + ".");
				} else {
					player.Message("There are no commands containing \"{0}\"", param.Trim('*'));
				}
                return;
            } else if (param.EndsWith("*")) {
                foreach (CommandDescriptor item in items) {
                    if (item.Name.ToLower().StartsWith(param.ToLower().Trim('*'))) {
                        output += item.MinRank.Color + item.Name + "&s, ";
                    }
                }
                player.Message("&sCommands starting with \"{0}\":", param.Trim('*'));
				if (output.EndsWith(", ")) {
					player.Message(output.Remove(output.Length - 2) + ".");
				} else {
					player.Message("There are no commands starting with \"{0}\"", param.Trim('*'));
				}
                return;
			} else if (param.StartsWith("*")) {
                foreach (CommandDescriptor item in items) {
                    if (item.Name.ToLower().EndsWith(param.ToLower().Trim('*'))) {
                        output += item.MinRank.Color + item.Name + "&s, ";
                    }
                }
                player.Message("&sCommands ending with \"{0}\":", param.Trim('*'));
				if (output.EndsWith(", ")) {
					player.Message(output.Remove(output.Length - 2) + ".");
				} else {
					player.Message("There are no commands ending with \"{0}\"", param.Trim('*'));
				}
				return;
			} else if (param.StartsWith("@")) {
                string rankName = param.Substring(1);
                Rank rank = RankManager.FindRank(rankName);
                if (rank == null) {
                    player.MessageNoRank(rankName);
                    return;
                }
                prefix = String.Format("Commands available to {0}&S", rank.ClassyName);
                cd = CommandManager.GetCommands(rank, false);
            } else if (param.Equals("all", StringComparison.OrdinalIgnoreCase)) {
                prefix = "All commands";
                cd = CommandManager.GetCommands();
            } else if (param.Equals("hidden", StringComparison.OrdinalIgnoreCase)) {
                prefix = "Hidden commands";
                cd = CommandManager.GetCommands(true);
            } else if (EnumUtil.TryComplete(param, out category, true)) {
                prefix = String.Format("{0} commands", category);
                cd = CommandManager.GetCommands(category, false);
            } else {
                CdCommands.PrintUsage(player);
                return;
            }
            player.MessagePrefixed("&S  ", "{0}: {1}", prefix, cd.JoinToClassyString());
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:82,代码来源:InfoCommands.cs

示例14: MaxPWHandler

 private static void MaxPWHandler(Player player, CommandReader cmd) {
     string rname = cmd.Next();
     string rmax = cmd.Next();
     Rank prank = player.Info.Rank;
     if (player.Info.Rank == RankManager.HighestRank) {
         if (rname == null) {
             player.Message("Rank ({0}&s) has a max of {1} personal worlds", prank.ClassyName,
                 prank.MaxPersonalWorlds);
             return;
         }
         Rank rank = RankManager.FindRank(rname);
         if (rank == null) {
             player.MessageNoRank(rname);
             return;
         }
         if (rmax == null) {
             player.Message("Rank ({0}&s) has a max of {1} personal worlds.", rank.ClassyName,
                 rank.MaxPersonalWorlds);
             return;
         }
         int max;
         if (!int.TryParse(rmax, out max)) {
             player.Message(CdMaxPW.Usage);
             return;
         }
         if (rank != null) {
             rank.MaxPersonalWorlds = max;
             player.Message("Set MaxPersonalWorlds for rank ({0}&s) to {1} personal worlds.", rank.ClassyName,
                 rank.MaxPersonalWorlds);
             Config.Save();
         }
     } else {
         player.Message("Rank ({0}&s) has a max of {1} personal worlds.", prank.ClassyName,
             prank.MaxPersonalWorlds);
         return;
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:37,代码来源:WorldCommands.cs

示例15: WorldLoadHandler

        static void WorldLoadHandler(Player player, Command cmd)
        {
            string fileName = cmd.Next();
            string worldName = cmd.Next();

            if (worldName == null && player.World == null)
            {
                player.Message("When using /WLoad from console, you must specify the world name.");
                return;
            }

            if (fileName == null)
            {
                // No params given at all
                CdWorldLoad.PrintUsage(player);
                return;
            }

            string fullFileName = WorldManager.FindMapFile(player, fileName);
            if (fullFileName == null) return;

            // Loading map into current world
            if (worldName == null)
            {
                if (!cmd.IsConfirmed)
                {
                    player.Confirm(cmd, "Replace THIS MAP with \"{0}\"?", fileName);
                    return;
                }
                Map map;
                try
                {
                    map = MapUtility.Load(fullFileName);
                }
                catch (Exception ex)
                {
                    player.MessageNow("Could not load specified file: {0}: {1}", ex.GetType().Name, ex.Message);
                    return;
                }
                World world = player.World;

                // Loading to current world
                world.MapChangedBy = player.Name;
                world.ChangeMap(map);

                world.Players.Message(player, "{0}&S loaded a new map for this world.",
                                              player.ClassyName);
                player.MessageNow("New map loaded for the world {0}", world.ClassyName);

                Logger.Log(LogType.UserActivity,
                            "{0} loaded new map for world \"{1}\" from {2}",
                            player.Name, world.Name, fileName);

            }
            else
            {
                // Loading to some other (or new) world
                if (!World.IsValidName(worldName))
                {
                    player.MessageInvalidWorldName(worldName);
                    return;
                }

                string buildRankName = cmd.Next();
                string accessRankName = cmd.Next();
                Rank buildRank = RankManager.DefaultBuildRank;
                Rank accessRank = null;
                if (buildRankName != null)
                {
                    buildRank = RankManager.FindRank(buildRankName);
                    if (buildRank == null)
                    {
                        player.MessageNoRank(buildRankName);
                        return;
                    }
                    if (accessRankName != null)
                    {
                        accessRank = RankManager.FindRank(accessRankName);
                        if (accessRank == null)
                        {
                            player.MessageNoRank(accessRankName);
                            return;
                        }
                    }
                }

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

//.........这里部分代码省略.........
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:101,代码来源:WorldCommands.cs


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