fCraft.ModerationCommands.BringHandler C# (CSharp) Method

BringHandler() private static method

private static BringHandler ( Player player, Command cmd ) : void
player Player
cmd Command
return void
        private static void BringHandler( Player player, Command 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, 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, 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 );
                target.Message( "&8You were summoned by {0}", player.ClassyName );
            } else {
                // teleport to a different world
                SecurityCheckResult check = world.AccessSecurity.CheckDetailed( target.Info );
                if ( check == SecurityCheckResult.RankTooHigh || check == SecurityCheckResult.RankTooLow ) {
                    if ( player.CanJoin( world ) ) {
                        if ( cmd.IsConfirmed ) {
                            BringPlayerToWorld( player, target, world, true, true );
                        } else {
                            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 );
                    target.Message( "&8You were summoned by {0}", player.ClassyName );
                }
            }
        }