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


C# Player.CanJoin方法代码示例

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


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

示例1: FindMainWorld

 public static World FindMainWorld( Player player ) {
     World rankMain = player.Info.Rank.MainWorld;
     if( rankMain != null && player.CanJoin( rankMain ) ) {
         return rankMain;
     } else {
         return MainWorld;
     }
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:WorldManager.cs

示例2: FindMainWorld

 public static World FindMainWorld( Player player ) {
     World rankMain = player.Info.Rank.MainWorld;
     if ((player.Info.TimesVisited == 1 || player.Info.HasRTR == false) && FindWorldExact("Tutorial") != null) return FindWorldOrPrintMatches(player, "Tutorial");
     if( rankMain != null && player.CanJoin( rankMain ) && player.Info.JoinOnRankWorld == true ) {
         return rankMain;
     } else {
         return MainWorld;
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:9,代码来源:WorldManager.cs

示例3: WorldBringHandler

        static void WorldBringHandler( Player player, CommandReader cmd ) {
            string playerName = cmd.Next();
            string worldName = cmd.Next();
            if( playerName == null || worldName == null ) {
                CdWorldBring.PrintUsage( player );
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches( player, playerName, false, false, true );
            World world = WorldManager.FindWorldOrPrintMatches( player, worldName );

            if( target == null || world == null ) return;

            if( !player.Can( Permission.Bring, target.Info.Rank ) ) {
                player.Message( "You may only bring players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit( Permission.Bring ).ClassyName );
                player.Message( "{0}&S is ranked {1}",
                                target.ClassyName, target.Info.Rank.ClassyName );
                return;
            }

            if( world == target.World ) {
                player.Message( "Player {0}&S is already in world {1}&S. They were brought to spawn.",
                                target.ClassyName, world.ClassyName );
                target.TeleportTo( target.WorldMap.Spawn );
                return;
            }

            SecurityCheckResult check = world.AccessSecurity.CheckDetailed( target.Info );
            if( check == SecurityCheckResult.RankTooLow ) {
                if( player.CanJoin( world ) ) {
                    if( cmd.IsConfirmed ) {
                        BringPlayerToWorld( player, target, world, true, false );
                    } else {
                        Logger.Log( LogType.UserActivity,
                                    "WBring: Asked {0} to confirm overriding world permissions to bring player {1} to world {2}",
                                    player.Name, target.Name, world.Name );
                        player.Confirm( cmd,
                                        "Player {0}&S is ranked too low to join {1}&S. Override world permissions?",
                                        target.ClassyName,
                                        world.ClassyName );
                    }
                } else {
                    player.Message( "Neither you nor {0}&S are allowed to join world {1}",
                                    target.ClassyName, world.ClassyName );
                }
            } else {
                BringPlayerToWorld( player, target, world, false, false );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:50,代码来源:ModerationCommands.cs

示例4: BringHandler

        static void BringHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                CdBring.PrintUsage( player );
                return;
            }

            // bringing someone to another player (instead of to self)
            string toName = cmd.Next();
            Player toPlayer = player;
            if( toName != null ) {
                toPlayer = Server.FindPlayerOrPrintMatches( player, toName, true, false, true );
                if( toPlayer == null ) return;
            } else if( toPlayer.World == null ) {
                player.Message( "When used from console, /Bring requires both names to be given." );
                return;
            }

            World world = toPlayer.World;
            if( world == null ) PlayerOpException.ThrowNoWorld( toPlayer );

            Player target = Server.FindPlayerOrPrintMatches( player, name, true, false, true );
            if( target == null ) return;

            if( !player.Can( Permission.Bring, target.Info.Rank ) ) {
                player.Message( "You may only bring players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit( Permission.Bring ).ClassyName );
                player.Message( "{0}&S is ranked {1}",
                                target.ClassyName, target.Info.Rank.ClassyName );
                return;
            }

            if( target.World == world ) {
                // teleport within the same world
                target.TeleportTo( toPlayer.Position );

            } else {
                // teleport to a different world
                SecurityCheckResult check = world.AccessSecurity.CheckDetailed( target.Info );
                if( check == SecurityCheckResult.RankTooLow ) {
                    if( player.CanJoin( world ) ) {
                        if( cmd.IsConfirmed ) {
                            BringPlayerToWorld( player, target, world, true, true );
                        } else {
                            Logger.Log( LogType.UserActivity,
                                        "Bring: Asked {0} to confirm overriding world permissions to bring player {1} to world {2}",
                                        player.Name, target.Name, world.Name );
                            player.Confirm( cmd,
                                            "Player {0}&S is ranked too low to join {1}&S. Override world permissions?",
                                            target.ClassyName,
                                            world.ClassyName );
                        }
                    } else {
                        player.Message( "Neither you nor {0}&S are allowed to join world {1}",
                                        target.ClassyName, world.ClassyName );
                    }
                } else {
                    BringPlayerToWorld( player, target, world, false, true );
                }
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:61,代码来源:ModerationCommands.cs

示例5: SetMainWorld

        static void SetMainWorld(Player player, World world)
        {
            if (world == WorldManager.MainWorld)
            {
                player.Message("World {0}&S is already set as main.", world.ClassyName);

            }
            else if (!player.Info.Rank.AllowSecurityCircumvention && !player.CanJoin(world))
            {
                // Prevent players from exploiting /WMain to gain access to restricted maps
                switch (world.AccessSecurity.CheckDetailed(player.Info))
                {
                    case SecurityCheckResult.RankTooHigh:
                    case SecurityCheckResult.RankTooLow:
                        player.Message("You are not allowed to set {0}&S as the main world (by rank).", world.ClassyName);
                        return;
                    case SecurityCheckResult.BlackListed:
                        player.Message("You are not allowed to set {0}&S as the main world (blacklisted).", world.ClassyName);
                        return;
                }

            }
            else
            {
                if (world.AccessSecurity.HasRestrictions)
                {
                    world.AccessSecurity.Reset();
                    player.Message("The main world cannot have access restrictions. " +
                                    "All access restrictions were removed from world {0}",
                                    world.ClassyName);
                }

                try
                {
                    WorldManager.MainWorld = world;
                }
                catch (WorldOpException ex)
                {
                    player.Message(ex.Message);
                    return;
                }

                WorldManager.SaveWorldList();

                Server.Message("{0}&S set {1}&S to be the main world.",
                                  player.ClassyName, world.ClassyName);
                Logger.Log(LogType.UserActivity,
                            "{0} set {1} to be the main world.",
                            player.Name, world.Name);
            }
        }
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:51,代码来源:WorldCommands.cs

示例6: WorldBringHandler

        static void WorldBringHandler( Player player, CommandReader cmd ) {
            string playerName = cmd.Next();
            string worldName = cmd.Next();
            if( playerName == null || worldName == null ) {
                CdWorldBring.PrintUsage( player );
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, playerName, SearchOptions.Default);
            World world = WorldManager.FindWorldOrPrintMatches( player, worldName );

            if( target == null || world == null ) return;

            if (target == player)
            {
                player.Message( "&WYou cannot &H/WBring&W yourself." );
                return;
            }

            if( !player.Can( Permission.Bring, target.Info.Rank ) ) {
                player.Message( "You may only bring players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit( Permission.Bring ).ClassyName );
                player.Message( "{0}&S is ranked {1}",
                                target.ClassyName, target.Info.Rank.ClassyName );
                return;
            }

            if( world == target.World ) {
                player.Message( "{0}&S is already in world {1}&S. They were brought to spawn.",
								target.ClassyName, world.ClassyName);

				if (target.World != null) {
					target.LastWorld = target.World;
					target.LastPosition = target.Position;
				}
                target.TeleportTo( target.WorldMap.Spawn );
                return;
            }

            SecurityCheckResult check = world.AccessSecurity.CheckDetailed( target.Info );
            if( check == SecurityCheckResult.RankTooLow ) {
                if( player.CanJoin( world ) ) {
                    if( cmd.IsConfirmed ) {
                        BringPlayerToWorld( player, target, world, true, false );
                    } else {
                        //Allow banned players to be moved about...
                        if (target.Info.Rank.Name == "Banned")
                        {
                            player.Message("&sYou CAN move banned players about... It is considered bad form though...");
                        }
                        Logger.Log( LogType.UserActivity,
                                    "WBring: Asked {0} to confirm overriding world permissions to bring player {1} to world {2}",
                                    player.Name, target.Name, world.Name );
                        player.Confirm( cmd,
                                        "{0} {1}&S is ranked too low to join {2}&S. Override world permissions?",
                                        target.Info.Rank.ClassyName,
                                        target.ClassyName,
                                        world.ClassyName );
                    }
                } else {
                    player.Message( "Neither you nor {0}&S are allowed to join world {1}",
                                    target.ClassyName, world.ClassyName );
                }
            } else {
                //Allow banned players to be moved about...
                if (target.Info.Rank.Name == "Banned")
                {
                    player.Message("&sYou CAN move banned players about... It is considered bad form though...");
                }
                BringPlayerToWorld( player, target, world, false, false );
            }
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:72,代码来源:ModerationCommands.cs

示例7: Worlds

        internal static void Worlds( Player player, Command cmd ) {
            string param = cmd.Next();
            bool listVisible = true,
                 listHidden = false,
                 listAllLoaded = false;
            if( !String.IsNullOrEmpty( param ) ) {
                switch( Char.ToLower( param[0] ) ) {
                    case 'a':
                        listHidden = true;
                        break;
                    case 'h':
                        listVisible = false;
                        listHidden = true;
                        break;
                    case 'l':
                        listAllLoaded = true;
                        listVisible = false;
                        listHidden = false;
                        break;
                    default:
                        cdWorlds.PrintUsage( player );
                        return;
                }
            }

            StringBuilder sb = new StringBuilder();
            bool first = true;
            int count = 0;

            World[] worldListCache = WorldManager.WorldList;
            foreach( World world in worldListCache ) {
                bool visible = player.CanJoin( world ) && !world.IsHidden;
                if( (world.IsLoaded && listAllLoaded) || (visible && listVisible) || (!visible && listHidden) ) {
                    if( !first ) {
                        sb.Append( ", " );
                    }
                    sb.Append( world.GetClassyName() );
                    count++;
                    first = false;
                }
            }

            if( listAllLoaded ) {
                player.MessagePrefixed( "&S   ", "There are " + count + " loaded worlds: " + sb );
            } else if( listVisible && !listHidden ) {
                player.MessagePrefixed( "&S   ", "There are " + count + " available worlds: " + sb );
            } else if( !listVisible ) {
                player.MessagePrefixed( "&S   ", "There are " + count + " hidden worlds: " + sb );
            } else {
                player.MessagePrefixed( "&S   ", "There are " + count + " worlds total: " + sb );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:52,代码来源:WorldCommands.cs

示例8: WorldMain

        internal static void WorldMain( Player player, Command cmd ) {
            string worldName = cmd.Next();
            if( worldName == null ) {
                player.Message( "Main world is {0}", WorldManager.MainWorld.GetClassyName() );
                return;
            }

            World world = WorldManager.FindWorldOrPrintMatches( player, worldName );
            if( world == null ) {
                return;

            } else if( world == WorldManager.MainWorld ) {
                player.Message( "World {0}&S is already set as main.", world.GetClassyName() );

            } else if( !player.Info.Rank.AllowSecurityCircumvention && !player.CanJoin( world ) ) {
                // Prevent players from exploiting /wmain to gain access to restricted maps
                switch( world.AccessSecurity.CheckDetailed( player.Info ) ) {
                    case SecurityCheckResult.RankTooHigh:
                    case SecurityCheckResult.RankTooLow:
                        player.Message( "You are not allowed to set {0}&S as the main world (by rank).", world.GetClassyName() );
                        return;
                    case SecurityCheckResult.BlackListed:
                        player.Message( "You are not allowed to set {0}&S as the main world (blacklisted).", world.GetClassyName() );
                        return;
                }

            } else {
                if( world.AccessSecurity.HasRestrictions() ) {
                    world.AccessSecurity.Reset();
                    player.Message( "The main world cannot have access restrictions. " +
                                    "All access restrictions were removed from world {0}",
                                    world.GetClassyName() );
                }

                if( !world.SetMainWorld() ) {
                    player.Message( "Main world was not changed." );
                    return;
                }
                WorldManager.SaveWorldList();

                Server.SendToAll( "{0}&S set {1}&S to be the main world.",
                                  player.GetClassyName(), world.GetClassyName() );
                Logger.Log( "{0} set {1} to be the main world.", LogType.UserActivity,
                            player.Name, world.Name );
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:46,代码来源:WorldCommands.cs

示例9: MWHandler


//.........这里部分代码省略.........
                    if (File.Exists("./maps/PW_" + player.Name + "_" + wNumberd + ".fcm")) {
                        File.Delete("./maps/PW_" + player.Name + "_" + wNumberd + ".fcm");
                    }
                    player.Message("Your personal world({0}) has been deleted!", wNumberd);
                    Server.RequestGC();
                    break;

                    #endregion

                    #region Join

                case "j":
                case "join":
                    string wNumberStringj = cmd.Next();
                    int wNumberj;
                    if (!int.TryParse(wNumberStringj, out wNumberj)) {
                        wNumberj = 1;
                    }
                    string playerStringj = cmd.Next();
                    PlayerInfo playerj = null;
                    if (playerStringj != null) {
                        playerj = PlayerDB.FindPlayerInfoOrPrintMatches(player, playerStringj, SearchOptions.Default);
                    }
                    string mapFilej = WorldManager.FindMapFile(Player.Console,
                        "PW_" + ((playerj == null) ? player.Name : playerj.Name) + "_" + wNumberj);
                    if (mapFilej == null) {
                        player.Message("{0} no personal worlds by that number: {1}",
                            (playerj == null) ? "You have" : "There are", wNumberj);
                        break;
                    }
                    World worldj =
                        WorldManager.FindWorldExact("PW_" + ((playerj == null) ? player.Name : playerj.Name) + "_" +
                                                    wNumberj);
                    if (worldj != null && player.CanJoin(worldj)) {
                        player.JoinWorld(worldj, WorldChangeReason.ManualJoin);
                    } else {
                        player.Message("You cannot join that world!");
                    }

                    break;

                    #endregion

                    #region BuildAccess

                case "buildaccess":
                case "ba":
                    string wNumberStringba = cmd.Next();
                    string exceptionba = cmd.Next();
                    int wNumberba;
                    bool changesWereMade = false;
                    if (!int.TryParse(wNumberStringba, out wNumberba)) {
                        wNumberba = 1;
                        exceptionba = wNumberStringba;
                    }
                    string mapFileba = WorldManager.FindMapFile(Player.Console, "PW_" + player.Name + "_" + wNumberba);
                    if (mapFileba == null) {
                        player.Message("You have no personal worlds by that number: {0}", wNumberba);
                        break;
                    }
                    World worldba = WorldManager.FindWorldExact("PW_" + player.Name + "_" + wNumberba);
                    if (exceptionba == null) {
                        CdMyWorld.PrintUsage(player);
                        break;
                    }
                    if (exceptionba.Equals("-*")) {
开发者ID:Magi1053,项目名称:ProCraft,代码行数:67,代码来源:WorldCommands.cs

示例10: WorldBringHandler

        static void WorldBringHandler( Player player, Command cmd )
        {
            string playerName = cmd.Next();
            string worldName = cmd.Next();
            if( playerName == null || worldName == null ) {
                CdBring.PrintUsage( player );
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches( player, playerName, false, true );
            World world = WorldManager.FindWorldOrPrintMatches( player, worldName );

            if( target == null || world == null ) return;

            if( target == player ) {
                player.Message( "&WYou cannot &H/WBring&W yourself." );
                return;
            }

            if( !player.Can( Permission.Bring, target.Info.Rank ) ) {
                player.Message( "You may only bring players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit( Permission.Bring ).ClassyName );
                player.Message( "{0}&S is ranked {1}",
                                target.ClassyName, target.Info.Rank.ClassyName );
                return;
            }

            if( world == target.World ) {
                player.Message( "Player {0}&S is already in world {1}",
                                target.ClassyName, world.ClassyName );
                return;
            }

            bool overridePermission = false;
            if( world.AccessSecurity.CheckDetailed( target.Info ) == SecurityCheckResult.RankTooLow && player.CanJoin( world ) ) {
                if( cmd.IsConfirmed ) {
                    overridePermission = true;
                } else {
                    player.Confirm( cmd,
                                    "Player {0}&S is ranked too low to join {1}&S. Override world permissions?",
                                    target.ClassyName, world.ClassyName );
                    return;
                }
            }

            BringPlayerToWorld( player, target, world, overridePermission, false );
        }
开发者ID:Desertive,项目名称:800craft,代码行数:47,代码来源:ModerationCommands.cs


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