Exemple #1
1
        static void SayHandler(Player player, CommandReader cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam()) return;

            if (player.Can(Permission.Say))
            {
                string msg = cmd.NextAll().Trim();
                if (msg.Length > 0)
                {
                    Chat.SendSay(player, msg);
                }
                else
                {
                    CdSay.PrintUsage(player);
                }
            }
            else
            {
                player.MessageNoAccess(Permission.Say);
            }
        }
Exemple #2
1
        void DoZone( Player player, Command cmd ) {
            if( !player.Can( Permissions.SetSpawn ) ) {
                world.NoAccessMessage( player );
                return;
            }

            string name = cmd.Next();
            if( name == null ) {
                player.Message( "No zone name specified. See " + Color.Help + "/help zone" );
                return;
            }
            if( !Player.IsValidName( name ) ) {
                player.Message( "\"" + name + "\" is not a valid zone name" );
                return;
            }
            Zone zone = new Zone();
            zone.name = name;

            string property = cmd.Next();
            if( property == null ) {
                player.Message( "No zone rank/whitelist/blacklist specified. See " + Color.Help + "/help zone" );
                return;
            }
            PlayerClass minRank = world.classes.ParseClass( property );
            
            if( minRank != null ) {
                zone.buildRank = minRank.rank;
                player.tag = zone;
                player.marksExpected = 2;
                player.marks.Clear();
                player.markCount = 0;
                player.selectionCallback = MakeZone;
            }
        }
Exemple #3
1
 internal static void CModeWater(Player player, Command cmd)
 {
     if (!player.Can(Permissions.ControlPhysics))
     {
         player.NoAccessMessage(Permissions.ControlPhysics);
         return;
     }
     string blockpar = cmd.Next();
     string wmt = "";
     int BlockAddr = -1;
     try { BlockAddr = Convert.ToInt32(blockpar); }
     catch
     {
         player.Message("Incorrect parameter!"); return;
     }
     if (BlockAddr < 3 && BlockAddr >= 0)
     {
         player.world.map.modeWater = BlockAddr;
         switch (BlockAddr)
         {
             case 0: wmt = "'none'"; break;
             case 1: wmt = "'infinite'"; break;
             case 2: wmt = "'finite'"; break;
         }
         player.Message("Water mode set to " + wmt + ".");
     }
 }
Exemple #4
0
        void Draw( Player player, Command command, DrawMode mode ) {
            if( !player.Can( Permissions.Draw ) ) {
                world.NoAccessMessage( player );
                return;
            }
            if( player.drawingInProgress ) {
                player.Message( "Another draw command is already in progress. Please wait." );
                return;
            }
            string blockName = command.Next();
            Block block;
            if( blockName == null || blockName == "" ) {
                if( mode == DrawMode.Cuboid ) {
                    player.Message( "Usage: " + Color.Help + "/cuboid blockName" + Color.Sys + " or " + Color.Help + "/cub blockName" );
                } else {
                    player.Message( "Usage: " + Color.Help + "/ellipsoid blockName" + Color.Sys + " or " + Color.Help + "/ell blockName" );
                }
                return;
            }
            try {
                block = Map.GetBlockByName( blockName );
            } catch( Exception ) {
                player.Message( "Unknown block name: " + blockName );
                return;
            }
            player.tag = block;

            Permissions permission = Permissions.Build;
            switch( block ) {
                case Block.Admincrete: permission = Permissions.PlaceAdmincrete; break;
                case Block.Air: permission = Permissions.Delete; break;
                case Block.Water:
                case Block.StillWater: permission = Permissions.PlaceWater; break;
                case Block.Lava:
                case Block.StillLava: permission = Permissions.PlaceLava; break;
            }
            if( !player.Can( permission ) ) {
                player.Message( "You are not allowed to draw with this block." );
                return;
            }

            player.marksExpected = 2;
            player.markCount = 0;
            player.marks.Clear();
            player.Message( mode.ToString() + ": Place a block or type /mark to use your location." );

            if( mode == DrawMode.Cuboid ) {
                player.selectionCallback = DrawCuboid;
            } else {
                player.selectionCallback = DrawEllipsoid;
            }
        }
Exemple #5
0
        void Save(Player player, Command cmd)
        {
            if (!player.Can(Permissions.SaveAndLoad))
            {
                world.NoAccessMessage(player);
                return;
            }

            string mapName = cmd.Next();

            if (mapName == null)
            {
                player.Message("Syntax: " + Color.Help + "/backup backupName");
                return;
            }

            string mapFileName = Path.GetFileName(mapName) + ".fcm";

            player.Message("Saving backup...");
            if (world.map.Save(mapFileName))
            {
                player.Message("Backup succesful.");
            }
            else
            {
                player.Message("Backup failed. See logfile for details.");
            }
        }
Exemple #6
0
 void UndoDraw(Player player, Command command)
 {
     if (!player.Can(Permissions.Draw))
     {
         world.NoAccessMessage(player);
         return;
     }
     if (player.drawUndoBuffer.Count > 0)
     {
         if (player.drawingInProgress)
         {
             player.Message("Cannot undo a drawing-in-progress. Wait for it to finish.");
         }
         else
         {
             world.SendToAll(Color.Sys + player.name + " initiated /drawundo. " + player.drawUndoBuffer.Count + " blocks to replace...", null);
             while (player.drawUndoBuffer.Count > 0)
             {
                 world.map.QueueUpdate(player.drawUndoBuffer.Dequeue());
             }
         }
         GC.Collect();
     }
     else
     {
         player.Message("There is currently nothing to undo.");
     }
 }
 void Freeze(Player player, Command cmd)
 {
     if (player.Can(Permissions.Freeze))
     {
         string name   = cmd.Next();
         Player target = world.FindPlayer(name);
         if (target != null)
         {
             if (!target.isFrozen)
             {
                 world.SendToAll(PacketWriter.MakeMessage(Color.Yellow + target.name + " has been frozen by " + player.name), null);
                 target.isFrozen = true;
             }
             else
             {
                 player.Message(target.name + " is already frozen.");
             }
         }
         else
         {
             world.NoPlayerMessage(player, name);
         }
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
 void Unfreeze(Player player, Command cmd)
 {
     if (player.Can(Permissions.Freeze))
     {
         string name   = cmd.Next();
         Player target = world.FindPlayer(name);
         if (target != null)
         {
             if (target.isFrozen)
             {
                 world.SendToAll(PacketWriter.MakeMessage(Color.Yellow + target.name + " is no longer frozen."), null);
                 target.isFrozen = false;
             }
             else
             {
                 player.Message(target.name + " is currently not frozen.");
             }
         }
         else
         {
             world.NoPlayerMessage(player, name);
         }
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #9
0
 static void BumHandler(Player player, CommandReader cmd)
 {
     string newModeName = cmd.Next();
     if (newModeName == null)
     {
         player.Message("&sBytes Sent: {0}  Per Second: {1:0.0}", player.BytesSent, player.BytesSentRate);
         player.Message("&sBytes Received: {0}  Per Second: {1:0.0}", player.BytesReceived, player.BytesReceivedRate);
         player.Message("&sBandwidth mode: {0}",player.BandwidthUseMode);
                         
                         
                         
         return;
     }
     else if (player.Can(Permission.EditPlayerDB))
     {
         var newMode = (BandwidthUseMode)Enum.Parse(typeof(BandwidthUseMode), newModeName, true);
         player.Message("&sBandwidth mode: {0} --> {1}", player.BandwidthUseMode, newMode.ToString());
         player.BandwidthUseMode = newMode;
         player.Info.BandwidthUseMode = newMode;
         return;
     }
     else
     {
         player.Message("You need {0}&s to change your BandwidthUseMode", RankManager.GetMinRankWithAnyPermission(Permission.EditPlayerDB).ClassyName);
         return;
     }
     
 }
Exemple #10
0
        internal static void DrawCuboid(Player player, Position[] marks, object tag)
        {
            player.drawingInProgress = true;
            Block drawBlock = (Block)tag;

            // find start/end coordinates
            int sx = Math.Min(marks[0].x, marks[1].x);
            int ex = Math.Max(marks[0].x, marks[1].x);
            int sy = Math.Min(marks[0].y, marks[1].y);
            int ey = Math.Max(marks[0].y, marks[1].y);
            int sh = Math.Min(marks[0].h, marks[1].h);
            int eh = Math.Max(marks[0].h, marks[1].h);

            int  blocks;
            byte block;
            int  step = 8;

            blocks = (ex - sx + 1) * (ey - sy + 1) * (eh - sh + 1);
            if (blocks > 2000000)
            {
                player.Message("NOTE: This draw command is too massive to undo.");
            }

            for (int x = sx; x <= ex; x += step)
            {
                for (int y = sy; y <= ey; y += step)
                {
                    for (int h = sh; h <= eh; h += step)
                    {
                        for (int h3 = 0; h3 < step && h + h3 <= eh; h3++)
                        {
                            for (int y3 = 0; y3 < step && y + y3 <= ey; y3++)
                            {
                                for (int x3 = 0; x3 < step && x + x3 <= ex; x3++)
                                {
                                    block = player.world.map.GetBlock(x + x3, y + y3, h + h3);
                                    if (block == (byte)drawBlock)
                                    {
                                        continue;
                                    }
                                    if (block == (byte)Block.Admincrete && !player.Can(Permissions.DeleteAdmincrete))
                                    {
                                        continue;
                                    }
                                    player.drawUndoBuffer.Enqueue(new BlockUpdate(Player.Console, x + x3, y + y3, h + h3, block));
                                    player.world.map.QueueUpdate(new BlockUpdate(Player.Console, x + x3, y + y3, h + h3, (byte)drawBlock));
                                }
                            }
                        }
                    }
                }
            }
            player.Message("Drawing " + blocks + " blocks... The map is now being updated.");
            player.world.log.Log("{0} initiated drawing a cuboid containing {1} blocks of type {2}.", LogType.UserActivity,
                                 player.name,
                                 blocks,
                                 drawBlock.ToString());
            GC.Collect();
            player.drawingInProgress = false;
        }
Exemple #11
0
        private static void CustomChatHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string message = cmd.NextAll().Trim();

            if (message.Length <= 0)
            {
                return;
            }
            if (player.Can(Permission.UseColorCodes) && message.Contains("%"))
            {
                message = Color.ReplacePercentCodes(message);
            }
            Chat.SendCustom(player, message);
        }
Exemple #12
0
        internal static void ThrowPlayerAndIPNotBanned([NotNull] Player player, [NotNull] PlayerInfo targetInfo, [NotNull] IPAddress address)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (targetInfo == null)
            {
                throw new ArgumentNullException("targetInfo");
            }
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            string msg, colorMsg;

            if (player.Can(Permission.ViewPlayerIPs))
            {
                msg = String.Format("Player {0} and their IP ({1}) are not currently banned.",
                                    targetInfo.Name, address);
                colorMsg = String.Format("&SPlayer {0}&S and their IP ({1}) are not currently banned.",
                                         targetInfo.ClassyName, address);
            }
            else
            {
                msg = String.Format("Player {0} and their IP are not currently banned.",
                                    targetInfo.Name);
                colorMsg = String.Format("&SPlayer {0}&S and their IP are not currently banned.",
                                         targetInfo.ClassyName);
            }
            throw new PlayerOpException(player, targetInfo, PlayerOpExceptionCode.NoActionNeeded, msg, colorMsg);
        }
Exemple #13
0
        internal static void ThrowNoOneToUnban([NotNull] Player player, [CanBeNull] PlayerInfo targetInfo, [NotNull] IPAddress address)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            string msg;

            if (player.Can(Permission.ViewPlayerIPs))
            {
                msg = String.Format("None of the players who use given IP ({0}) are banned.",
                                    address);
            }
            else
            {
                msg = "None of the players who use given IP are banned.";
            }
            string colorMsg = "&S" + msg;

            throw new PlayerOpException(player, targetInfo, PlayerOpExceptionCode.NoActionNeeded, msg, colorMsg);
        }
Exemple #14
0
        static void SayHandler(Player player, CommandReader cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            if (player.Can(Permission.Say))
            {
                string msg = cmd.NextAll().Trim(' ');
                if (msg.Length > 0)
                {
                    Chat.SendSay(player, msg);
                }
                else
                {
                    CdSay.PrintUsage(player);
                }
            }
            else
            {
                player.MessageNoAccess(Permission.Say);
            }
        }
        void Nick(Player player, Command cmd)
        {
            if (!player.Can(Permissions.ChangeName))
            {
                world.NoAccessMessage(player);
                return;
            }
            string name = cmd.Next();

            if (name == null)
            {
                if (player.nick != player.name)
                {
                    world.SendToAll(Color.Sys + player.nick + " is now known as " + player.name, player);
                    player.Message("You are now known as " + name + ". Use " + Color.Help + "/nick" + Color.Sys + " again to reset.");
                    player.nick = player.name;
                    world.UpdatePlayer(player);
                }
                else
                {
                    player.Message("You do not have an alias set.");
                }
            }
            else if (Player.IsValidName(name))
            {
                world.SendToAll(Color.Sys + player.nick + " is now known as " + name, player);
                player.Message("You are now known as " + name + ". Use " + Color.Help + "/nick" + Color.Sys + " again to reset.");
                player.nick = name;
                world.UpdatePlayer(player);
            }
            else
            {
                player.Message("Invalid player name.");
            }
        }
Exemple #16
0
        static void MeHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string msg = cmd.NextAll().Trim();

            if (msg.Length > 0)
            {
                player.Info.ProcessMessageWritten();
                if (player.Can(Permission.UseColorCodes) && msg.Contains("%"))
                {
                    msg = Color.ReplacePercentCodes(msg);
                }
                Chat.SendMe(player, msg);
            }
        }
Exemple #17
0
 public override void PrintUsage(Player player)
 {
     base.PrintUsage(player);
     if (player.Can(Permission.ManageGlobalChat))
     {
         player.Message("&H/Global Message | Help | Accept | Rules | Ignore | Reconnect");
     }
 }
Exemple #18
0
        /// <summary> Checks if a zone name makes it a special zone, and if so, whether the player can manage the special zone. </summary>
        public static bool CanManage(string name, Player player, string action)
        {
            if (name == null)
            {
                return(false);
            }
            Rank rank = RankManager.GetMinRankWithAnyPermission(Permission.ManageSpecialZones);

            if (name.CaselessStarts(Command) || name.CaselessStarts(ConsoleCommand))
            {
                if (player.Info.Rank == RankManager.HighestRank && player.Can(Permission.ManageSpecialZones))
                {
                    return(true);
                }

                if (rank != null)
                {
                    player.Message("You must be {0}&S to {1} command zone.", RankManager.HighestRank.ClassyName, action);
                }
                else
                {
                    player.Message("No rank has permission to {0} command zone.", action);
                }
                return(false);
            }
            else if (IsSpecialAffect(name) || IsSpecialMove(name))
            {
                if (player.Can(Permission.ManageSpecialZones))
                {
                    return(true);
                }

                if (rank != null)
                {
                    player.Message("You must be {0}&S to {1} special zone.", rank.ClassyName, action);
                }
                else
                {
                    player.Message("No rank has permission to {0} special zone.", action);
                }
                return(false);
            }
            return(true);
        }
        internal static void ThrowNoOneToBan([NotNull] Player player, [CanBeNull] PlayerInfo targetInfo, [NotNull] IPAddress address)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            string msg, colorMsg;

            if (targetInfo == null)
            {
                if (player.Can(Permission.ViewPlayerIPs))
                {
                    msg = String.Format("Given IP ({0}) and all players who use it are already banned.",
                                        address);
                }
                else
                {
                    msg = "Given IP and all players who use it are already banned.";
                }
                colorMsg = "&S" + msg;
            }
            else
            {
                if (player.Can(Permission.ViewPlayerIPs))
                {
                    msg = String.Format("Player {0}, their IP ({1}), and all players who use this IP are already banned.",
                                        targetInfo.Name, address);
                    colorMsg = String.Format("&SPlayer {0}&S, their IP ({1}), and all players who use this IP are already banned.",
                                             targetInfo.ClassyName, address);
                }
                else
                {
                    msg = String.Format("Player {0}, their IP, and all players who use this IP are already banned.",
                                        targetInfo.Name);
                    colorMsg = String.Format("&SPlayer {0}&S, their IP, and all players who use this IP are already banned.",
                                             targetInfo.ClassyName);
                }
            }
            throw new PlayerOpException(player, targetInfo, PlayerOpExceptionCode.NoActionNeeded, msg, colorMsg);
        }
Exemple #20
0
        internal static void ThrowPermissionLimitIP([NotNull] Player player, [NotNull] PlayerInfo infoWhomPlayerCantBan,
                                                    [NotNull] IPAddress targetAddress)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (infoWhomPlayerCantBan == null)
            {
                throw new ArgumentNullException("infoWhomPlayerCantBan");
            }
            if (targetAddress == null)
            {
                throw new ArgumentNullException("targetAddress");
            }

            string msg, colorMsg;

            if (player.Can(Permission.ViewPlayerIPs))
            {
                msg =
                    String.Format(
                        "IP {0} is used by player {1}, ranked {2}. You may only ban players ranked {3} and below.",
                        targetAddress,
                        infoWhomPlayerCantBan.Name,
                        infoWhomPlayerCantBan.Rank.Name,
                        player.Info.Rank.GetLimit(Permission.Ban).Name);
                colorMsg =
                    String.Format(
                        "&SIP {0} is used by player {1}&S, ranked {2}&S. You may only ban players ranked {3}&S and below.",
                        targetAddress,
                        infoWhomPlayerCantBan.ClassyName,
                        infoWhomPlayerCantBan.Rank.ClassyName,
                        player.Info.Rank.GetLimit(Permission.Ban).ClassyName);
            }
            else
            {
                msg =
                    String.Format(
                        "Given IP is used by player {0}, ranked {1}. You may only ban players ranked {2} and below.",
                        infoWhomPlayerCantBan.Name,
                        infoWhomPlayerCantBan.Rank.Name,
                        player.Info.Rank.GetLimit(Permission.Ban).Name);
                colorMsg =
                    String.Format(
                        "&SGiven IP is used by player {0}&S, ranked {1}&S. You may only ban players ranked {2}&S and below.",
                        infoWhomPlayerCantBan.ClassyName,
                        infoWhomPlayerCantBan.Rank.ClassyName,
                        player.Info.Rank.GetLimit(Permission.Ban).ClassyName);
            }
            throw new PlayerOpException(player,
                                        infoWhomPlayerCantBan,
                                        PlayerOpExceptionCode.PermissionLimitTooLow,
                                        msg,
                                        colorMsg);
        }
Exemple #21
0
        private static void TrollHandler( Player player, CommandReader cmd ) {
            string Name = cmd.Next();
            if ( Name == null ) {
                player.Message( "Player not found. Please specify valid name." );
                return;
            }
            if ( !Player.IsValidPlayerName( Name ) )
                return;
            Player target = Server.FindPlayerOrPrintMatches( player, Name, SearchOptions.Default );
            if ( target == null )
                return;
            string options = cmd.Next();
            if ( options == null ) {
                CdTroll.PrintUsage( player );
                return;
            }
            string Message = cmd.NextAll();
            if ( Message.Length < 1 && options.ToLower() != "leave" ) {
                player.Message( "&WError: Please enter a message for {0}.", target.ClassyName );
                return;
            }
            switch ( options.ToLower() ) {
                case "pm":
                    if ( player.Can( Permission.UseColorCodes ) && Message.Contains( "%" ) ) {
                        Message = Chat.ReplacePercentColorCodes( Message, false );
                    }
                    Server.Players.Message( "&Pfrom {0}: {1}",
                        target.Name, Message );
                    break;

                case "st":
                case "staff":
                    Chat.SendStaff( target, Message );
                    break;

                case "i":
                case "impersonate":
                case "msg":
                case "message":
                case "m":
                    Server.Message( "{0}&S&F: {1}",
                                      target.ClassyName, Message );
                    break;

                case "leave":
                case "disconnect":
                case "gtfo":
                    Server.Players.Message( "&SPlayer {0}&S left the server.",
                        target.ClassyName );
                    break;

                default:
                    player.Message( "Invalid option. Please choose st, ac, pm, message or leave" );
                    break;
            }
        }
Exemple #22
0
 void Unlock(Player player, Command cmd)
 {
     if (!player.Can(Permissions.Lock))
     {
         world.NoAccessMessage(player);
         return;
     }
     world.SendToAll(PacketWriter.MakeMessage(Color.Red + "Lockdown has ended."), null);
     world.EndLockDown();
 }
Exemple #23
0
 void Lock(Player player, Command cmd)
 {
     if (!player.Can(Permissions.Lock))
     {
         world.NoAccessMessage(player);
         return;
     }
     world.SendToAll(PacketWriter.MakeMessage(Color.Red + "Server is now on lockdown!"), null);
     world.BeginLockDown();
 }
Exemple #24
0
 void Grass( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Grass ) {
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Grass: OFF" );
     } else if( player.Can( Permissions.PlaceGrass ) ) {
         player.mode = BlockPlacementMode.Grass;
         player.Message( "Grass: ON. Dirt blocks are replaced with grass." );
     } else {
         world.NoAccessMessage( player );
     }
 }
Exemple #25
0
 void Water( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Water ) {
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Water: OFF" );
     } else if( player.Can( Permissions.PlaceWater ) ) {
         player.mode = BlockPlacementMode.Water;
         player.Message( "Water: ON. Blue blocks are replaced with water." );
     } else {
         world.NoAccessMessage( player );
     }
 }
Exemple #26
0
 void Lava( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Lava ) {
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Lava: OFF." );
     } else if( player.Can( Permissions.PlaceWater ) ) {
         player.mode = BlockPlacementMode.Lava;
         player.Message( "Lava: ON. Red blocks are replaced with lava." );
     } else {
         world.NoAccessMessage( player );
     }
 }
 void TP(Player player, Command cmd)
 {
     if (player.Can(Permissions.Teleport))
     {
         string name = cmd.Next();
         if (name == null)
         {
             player.Send(PacketWriter.MakeTeleport(255, world.map.spawn));
         }
         else
         {
             Player target = world.FindPlayer(name);
             if (target != null)
             {
                 Position pos = target.pos;
                 pos.x += 1;
                 pos.y += 1;
                 pos.h += 1;
                 player.Send(PacketWriter.MakeTeleport(255, pos));
             }
             else if (cmd.Next() == null)
             {
                 world.NoPlayerMessage(player, name);
             }
             else
             {
                 cmd.Rewind();
                 int x, y, h;
                 if (cmd.NextInt(out x) && cmd.NextInt(out y) && cmd.NextInt(out h))
                 {
                     if (x < 0 || x > world.map.widthX ||
                         y < 0 || y > world.map.widthY ||
                         y < 0 || y > world.map.height)
                     {
                         player.Message("Specified coordinates are outside the map!");
                     }
                     else
                     {
                         player.pos.Set(x * 32 + 16, y * 32 + 16, h * 32 + 16, player.pos.r, player.pos.l);
                         player.Send(PacketWriter.MakeTeleport(255, player.pos));
                     }
                 }
                 else
                 {
                     player.Message("See " + Color.Help + "/help tp" + Color.Sys + " for information on using /tp");
                 }
             }
         }
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #28
0
 void Solid( Player player, Command cmd ) {
     if( player.mode == BlockPlacementMode.Solid ){
         player.mode = BlockPlacementMode.Normal;
         player.Message( "Solid: OFF" );
     } else if( player.Can( Permissions.PlaceAdmincrete ) ) {
         player.mode = BlockPlacementMode.Solid;
         player.Message( "Solid: ON" );
     } else {
         world.NoAccessMessage( player );
     }
 }
Exemple #29
0
        public static Packet MakeSetPermission([NotNull] Player player)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            Packet packet = new Packet(OpCode.SetPermission);

            packet.Bytes[1] = (byte)(player.Can(Permission.DeleteAdmincrete) ? 100 : 0);
            return(packet);
        }
Exemple #30
0
 internal static void Hardened(Player player, Command cmd)
 {
     if (player.hardenedMode == BlockPlacementMode.Hardened) {
         player.hardenedMode = BlockPlacementMode.Normal;
         player.Message("Hardened blocks: OFF");
     } else if (player.Can(Permissions.PlaceHardenedBlocks)) {
         player.hardenedMode = BlockPlacementMode.Hardened;
         player.Message("Hardened blocks: ON");
     } else {
         player.NoAccessMessage( Permissions.PlaceHardenedBlocks );
     }
 }
Exemple #31
0
        internal static void Say( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MutedMessage();
                return;
            }

            if( player.Can( Permission.Say ) ) {
                string msg = cmd.NextAll();
                if( player.Can( Permission.UseColorCodes ) && msg.Contains( "%" ) ) {
                    msg = Color.ReplacePercentCodes( msg );
                }
                if( msg != null && msg.Trim().Length > 0 ) {
                    player.Info.LinesWritten++;
                    Server.SendToAllExceptIgnored( player, "&Y{0}", null, msg.Trim() );
                    IRC.SendAction( String.Format( "&Y{0}", msg.Trim() ) );
                } else {
                    cdSay.PrintUsage( player );
                }
            } else {
                player.NoAccessMessage( Permission.Say );
            }
        }
Exemple #32
0
        static void SayHandler( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MessageMuted();
                return;
            }

            if( player.DetectChatSpam() ) return;

            if( player.Can( Permission.Say ) ) {
                string msg = cmd.NextAll().Trim();
                if( player.Can( Permission.UseColorCodes ) && msg.Contains( "%" ) ) {
                    msg = Color.ReplacePercentCodes( msg );
                }
                if( msg.Length > 0 ) {
                    Chat.SendSay( player, msg );
                } else {
                    CdSay.PrintUsage( player );
                }
            } else {
                player.MessageNoAccess( Permission.Say );
            }
        }
 void SetSpawn(Player player, Command cmd)
 {
     if (player.Can(Permissions.SetSpawn))
     {
         world.map.spawn = player.pos;
         world.map.Save();
         world.map.changesSinceBackup++;
         player.Send(PacketWriter.MakeTeleport(255, world.map.spawn), true);
         player.Message("New spawn point saved.");
         world.log.Log("{0} changed the spawned point.", LogType.UserActivity, player.name);
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #34
0
        internal static Packet MakeHandshake( Player player, string serverName, string motd )
        {
            if ( player == null )
                throw new ArgumentNullException( "player" );
            if ( serverName == null )
                throw new ArgumentNullException( "serverName" );
            if ( motd == null )
                throw new ArgumentNullException( "motd" );

            Packet packet = new Packet( OpCode.Handshake );
            packet.Data[1] = Config.ProtocolVersion;
            Encoding.ASCII.GetBytes( serverName.PadRight( 64 ), 0, 64, packet.Data, 2 );
            Encoding.ASCII.GetBytes( motd.PadRight( 64 ), 0, 64, packet.Data, 66 );
            packet.Data[130] = ( byte )( player.Can( Permission.DeleteAdmincrete ) ? 100 : 0 );
            return packet;
        }
Exemple #35
0
 void Solid(Player player, Command cmd)
 {
     if (player.mode == BlockPlacementMode.Solid)
     {
         player.mode = BlockPlacementMode.Normal;
         player.Message("Solid: OFF");
     }
     else if (player.Can(Permissions.PlaceAdmincrete))
     {
         player.mode = BlockPlacementMode.Solid;
         player.Message("Solid: ON");
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #36
0
 void Grass(Player player, Command cmd)
 {
     if (player.mode == BlockPlacementMode.Grass)
     {
         player.mode = BlockPlacementMode.Normal;
         player.Message("Grass: OFF");
     }
     else if (player.Can(Permissions.PlaceGrass))
     {
         player.mode = BlockPlacementMode.Grass;
         player.Message("Grass: ON. Dirt blocks are replaced with grass.");
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #37
0
 void Water(Player player, Command cmd)
 {
     if (player.mode == BlockPlacementMode.Water)
     {
         player.mode = BlockPlacementMode.Normal;
         player.Message("Water: OFF");
     }
     else if (player.Can(Permissions.PlaceWater))
     {
         player.mode = BlockPlacementMode.Water;
         player.Message("Water: ON. Blue blocks are replaced with water.");
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #38
0
 void Lava(Player player, Command cmd)
 {
     if (player.mode == BlockPlacementMode.Lava)
     {
         player.mode = BlockPlacementMode.Normal;
         player.Message("Lava: OFF.");
     }
     else if (player.Can(Permissions.PlaceWater))
     {
         player.mode = BlockPlacementMode.Lava;
         player.Message("Lava: ON. Red blocks are replaced with lava.");
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
 internal static void Bring( Player player, Command cmd )
 {
     if( player.Can( Permissions.Bring ) ) {
         string name = cmd.Next();
         Player target = player.world.FindPlayer( name );
         if( target != null ) {
             Position pos = player.pos;
             pos.x += 1;
             pos.y += 1;
             pos.h += 1;
             target.Send( PacketWriter.MakeTeleport( 255, pos ) );
         } else {
             player.NoPlayerMessage( name );
         }
     } else {
         player.NoAccessMessage( Permissions.Bring );
     }
 }
 void Say(Player player, Command cmd)
 {
     if (player.Can(Permissions.Say))
     {
         string msg = cmd.NextAll();
         if (msg != null && msg.Trim().Length > 0)
         {
             world.SendToAll(PacketWriter.MakeMessage(Color.Say + msg.Trim()), null);
         }
         else
         {
             player.Message("Usage: " + Color.Help + "/say message");
         }
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #41
0
        /// <summary> Creates a new Handshake (0x00) packet. </summary>
        /// <param name="serverName"> Server name, to be shown on recipient's loading screen. May not be null. </param>
        /// <param name="player"> Player to whom this packet is being sent.
        /// Used to determine DeleteAdmincrete permission, for client-side checks. May not be null. </param>
        /// <param name="motd"> Message-of-the-day (text displayed below the server name). May not be null. </param>
        /// <exception cref="ArgumentNullException"> player, serverName, or motd is null </exception>
        public static Packet MakeHandshake([NotNull] Player player, [NotNull] string serverName, [NotNull] string motd)
        {
            if (serverName == null)
            {
                throw new ArgumentNullException("serverName");
            }
            if (motd == null)
            {
                throw new ArgumentNullException("motd");
            }

            Packet packet = new Packet(OpCode.Handshake);

            packet.Bytes[1] = Config.ProtocolVersion;
            Encoding.ASCII.GetBytes(serverName.PadRight(64), 0, 64, packet.Bytes, 2);
            Encoding.ASCII.GetBytes(motd.PadRight(64), 0, 64, packet.Bytes, 66);
            packet.Bytes[130] = (byte)(player.Can(Permission.DeleteAdmincrete) ? 100 : 0);
            return(packet);
        }
Exemple #42
0
        void DoZone(Player player, Command cmd)
        {
            if (!player.Can(Permissions.SetSpawn))
            {
                world.NoAccessMessage(player);
                return;
            }

            string name = cmd.Next();

            if (name == null)
            {
                player.Message("No zone name specified. See " + Color.Help + "/help zone");
                return;
            }
            if (!Player.IsValidName(name))
            {
                player.Message("\"" + name + "\" is not a valid zone name");
                return;
            }
            Zone zone = new Zone();

            zone.name = name;

            string property = cmd.Next();

            if (property == null)
            {
                player.Message("No zone rank/whitelist/blacklist specified. See " + Color.Help + "/help zone");
                return;
            }
            PlayerClass minRank = world.classes.ParseClass(property);

            if (minRank != null)
            {
                zone.buildRank       = minRank.rank;
                player.tag           = zone;
                player.marksExpected = 2;
                player.marks.Clear();
                player.markCount         = 0;
                player.selectionCallback = MakeZone;
            }
        }
Exemple #43
0
        private static void SpringHandler(Player player, Command cmd)        //for /spring
        {
            string revolutions = cmd.Next();
            int    rev;
            bool   parsed = Int32.TryParse(revolutions, out rev); //tries to convert input to int

            if (player.Can(Permission.DrawAdvanced))
            {
                PrepareSpring.SetParametrization(player, new Command("/scp x=(1+0.2*cos(2*pi*v))*sin(2*pi*u)"));
                PrepareSpring.SetParametrization(player, new Command("/scp y=(1+0.2*cos(2*pi*v))*cos(2*pi*u)"));
                PrepareSpring.SetParametrization(player, new Command("/scp z=u+0.2*sin(2*pi*v)"));

                if (revolutions == null || rev == 1)     //if number of revolutions isnt specified, just does 1
                {
                    PrepareSpring.SetParamIteration(player, new Command("/spi u 0 1 0.005"));
                    PrepareSpring.SetParamIteration(player, new Command("/spi v 0 1 0.005"));
                }

                else if (rev > 9 || rev <= 0)        //The greatest number of revolutions without having to adjust the number of iteration steps. I would adjust the number
                {                                    // of iterations per requested number of revolutions, but it would make the spring look like the blocks were placed too sparingly.
                    player.Message("The number of revolutions must be between 1 and 9.");
                    return;
                }

                else if (rev > 1 && rev < 5)         //different amount of iteration steps when different number of revolutions. Makes the springs look more filled in.
                {
                    PrepareSpring.SetParamIteration(player, new Command("/spi u 0 " + rev + " 0.005"));
                    PrepareSpring.SetParamIteration(player, new Command("/spi v 0 " + rev + " 0.005"));
                }

                else if (rev <= 9 && rev >= 5)       //different amount of iteration steps when different number of revolutions. Makes the springs look more filled in.
                {
                    PrepareSpring.SetParamIteration(player, new Command("/spi u 0 " + rev + " 0.0099"));
                    PrepareSpring.SetParamIteration(player, new Command("/spi v 0 " + rev + " 0.0099"));
                }
                StartCmdDraw(player, new Command("/spd uu"));       //uses custom handler as to not display messages to the user
            }
            else
            {
                CdSpring.PrintUsage(player);
            }
        }
Exemple #44
0
        internal static void StaffChat(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MutedMessage();
                return;
            }

            if (DateTime.UtcNow < player.Info.MutedUntil)
            {
                player.Message("You are muted for another {0:0} seconds.",
                               player.Info.MutedUntil.Subtract(DateTime.UtcNow).TotalSeconds);
                return;
            }


            Player[] plist = Server.PlayerList;

            if (plist.Length > 0)
            {
                player.Info.LinesWritten++;
            }

            string message = cmd.NextAll();

            if (message != null && message.Trim().Length > 0)
            {
                message = message.Trim();
                if (player.Can(Permission.UseColorCodes) && message.Contains("%"))
                {
                    message = Color.ReplacePercentCodes(message);
                }
                for (int i = 0; i < plist.Length; i++)
                {
                    if ((plist[i].Can(Permission.ReadStaffChat) || plist[i] == player) && !plist[i].IsIgnoring(player.Info))
                    {
                        plist[i].Message("{0}(staff){1}{0}: {2}", Color.PM, player.GetClassyName(), message);
                    }
                }
            }
        }
Exemple #45
0
        /// <summary> Parses and calls a specified command. </summary>
        /// <param name="player"> Player who issued the command. </param>
        /// <param name="cmd"> Command to be parsed and executed. </param>
        /// <param name="fromConsole"> Whether this command is being called from a non-player (e.g. Console). </param>
        public static void ParseCommand(Player player, Command cmd, bool fromConsole)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            CommandDescriptor descriptor = GetDescriptor(cmd.Name);

            if (descriptor == null)
            {
                player.Message("Unknown command \"{0}\". See &H/help commands", cmd.Name);
                return;
            }

            if (!descriptor.IsConsoleSafe && fromConsole)
            {
                player.Message("You cannot use this command from console.");
            }
            else
            {
                if (descriptor.Permissions != null)
                {
                    if (player.Can(descriptor.Permissions))
                    {
                        descriptor.Call(player, cmd, true);
                    }
                    else
                    {
                        player.NoAccessMessage(descriptor.Permissions);
                    }
                }
                else
                {
                    descriptor.Call(player, cmd, true);
                }
            }
        }
Exemple #46
0
 void Nick( Player player, Command cmd ) {
     if( !player.Can( Permissions.ChangeName ) ) {
         world.NoAccessMessage( player );
         return;
     }
     string name = cmd.Next();
     if( name == null ) {
         if( player.nick != player.name ) {
             world.SendToAll( Color.Sys + player.nick + " is now known as " + player.name, player );
             player.Message( "You are now known as " + name + ". Use " + Color.Help + "/nick" + Color.Sys + " again to reset." );
             player.nick = player.name;
             world.UpdatePlayer( player );
         } else {
             player.Message( "You do not have an alias set." );
         }
     } else if( Player.IsValidName( name ) ) {
         world.SendToAll( Color.Sys + player.nick + " is now known as " + name, player );
         player.Message( "You are now known as " + name + ". Use " + Color.Help + "/nick" + Color.Sys + " again to reset." );
         player.nick = name;
         world.UpdatePlayer( player );
     } else {
         player.Message( "Invalid player name." );
     }
 }
        static void ImportHandler( Player player, Command cmd )
        {
            string action = cmd.Next();
            if( action == null ) {
                CdImport.PrintUsage( player );
                return;
            }

            switch( action.ToLower() ) {
                case "bans":
                    if( !player.Can( Permission.Ban ) ) {
                        player.MessageNoAccess( Permission.Ban );
                        return;
                    }
                    ImportBans( player, cmd );
                    break;

                case "ranks":
                    if( !player.Can( Permission.Promote ) ) {
                        player.MessageNoAccess( Permission.Promote );
                        return;
                    }
                    ImportRanks( player, cmd );
                    break;

                default:
                    CdImport.PrintUsage( player );
                    break;
            }
        }
        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;

                case "banreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "BanReason", info, info.BanReason, valName ) ) {
                        info.BanReason = valName;
                    }
                    return;

                case "unbanreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "UnbanReason", info, info.UnbanReason, valName ) ) {
                        info.UnbanReason = valName;
                    }
                    return;

                case "rankreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "RankReason", info, info.RankChangeReason, valName ) ) {
                        info.RankChangeReason = valName;
                    }
                    return;

                case "kickreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "KickReason", info, info.LastKickReason, valName ) ) {
                        info.LastKickReason = valName;
                    }
                    return;

                case "displayedname":
                    string oldDisplayedName = info.DisplayedName;
                    if( player.Can( Permission.UseColorCodes ) ) {
                        valName = Color.ReplacePercentCodes( valName );
                    }
                    if( valName.Length == 0 ) valName = null;
                    if( valName == info.DisplayedName ) {
                        if( valName == null ) {
                            player.Message( "SetInfo: DisplayedName for {0} is not set.",
                                            info.Name );
                        } else {
                            player.Message( "SetInfo: DisplayedName for {0} is already set to \"{1}&S\"",
                                            info.Name,
                                            valName );
                        }
                        return;
                    }
                    info.DisplayedName = valName;

                    if( oldDisplayedName == null ) {
                        player.Message( "SetInfo: DisplayedName for {0} set to \"{1}&S\"",
                                        info.Name,
                                        valName );
                    } else if( valName == null ) {
                        player.Message( "SetInfo: DisplayedName for {0} was reset (was \"{1}&S\")",
                                        info.Name,
                                        oldDisplayedName );
                    } else {
                        player.Message( "SetInfo: DisplayedName for {0} changed from \"{1}&S\" to \"{2}&S\"",
                                        info.Name,
                                        oldDisplayedName,
                                        valName );
                    }
                    return;

                default:
                    player.Message( "Only the following properties are editable: " +
                                    "TimesKicked, PreviousRank, TotalTime, RankChangeType, " +
                                    "BanReason, UnbanReason, RankReason, KickReason, DisplayedName" );
                    return;
            }
        }
Exemple #49
0
        static void BindHandler( Player player, CommandReader cmd ) {
            if( !cmd.HasNext ) {
                player.Message( "All bindings have been reset." );
                player.ResetAllBinds();
                return;
            }

            Block originalBlock;
            if( !cmd.NextBlock( player, false, out originalBlock ) ) return;

            if( !cmd.HasNext ) {
                if( player.GetBind( originalBlock ) != originalBlock ) {
                    player.Message( "{0} is no longer bound to {1}",
                                    originalBlock,
                                    player.GetBind( originalBlock ) );
                    player.ResetBind( originalBlock );
                } else {
                    player.Message( "{0} is not bound to anything.",
                                    originalBlock );
                }
                return;
            }

            Block replacementBlock;
            if( !cmd.NextBlock( player, false, out replacementBlock ) ) return;

            if( cmd.HasNext ) {
                CdBind.PrintUsage( player );
                return;
            }

            Permission permission = Permission.Build;
            switch( replacementBlock ) {
                case Block.Grass:
                    permission = Permission.PlaceGrass;
                    break;
                case Block.Admincrete:
                    permission = Permission.PlaceAdmincrete;
                    break;
                case Block.Water:
                    permission = Permission.PlaceWater;
                    break;
                case Block.Lava:
                    permission = Permission.PlaceLava;
                    break;
            }
            if( player.Can( permission ) ) {
                player.Bind( originalBlock, replacementBlock );
                player.Message( "{0} is now replaced with {1}", originalBlock, replacementBlock );
            } else {
                player.Message( "&WYou do not have {0} permission.", permission );
            }
        }
Exemple #50
0
        static void InfoHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( name == null ) {
                // no name given, print own info
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( name.Equals( player.Name, StringComparison.OrdinalIgnoreCase ) ) {
                // own name given
                player.LastUsedPlayerName = player.Name;
                PrintPlayerInfo( player, player.Info );
                return;

            } else if( !player.Can( Permission.ViewOthersInfo ) ) {
                // someone else's name or IP given, permission required.
                player.MessageNoAccess( Permission.ViewOthersInfo );
                return;
            }

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

            PlayerInfo[] infos;
            IPAddress ip;

            if( name.Contains( "/" ) ) {
                // IP range matching (CIDR notation)
                string ipString = name.Substring( 0, name.IndexOf( '/' ) );
                string rangeString = name.Substring( name.IndexOf( '/' ) + 1 );
                byte range;
                if( IPAddressUtil.IsIP( ipString ) && IPAddress.TryParse( ipString, out ip ) &&
                    Byte.TryParse( rangeString, out range ) && range <= 32 ) {
                    player.Message( "Searching {0}-{1}", ip.RangeMin( range ), ip.RangeMax( range ) );
                    infos = PlayerDB.FindPlayersCidr( ip, range );
                } else {
                    player.Message( "Info: Invalid IP range format. Use CIDR notation." );
                    return;
                }

            } else if( IPAddressUtil.IsIP( name ) && IPAddress.TryParse( name, out ip ) ) {
                // find players by IP
                infos = PlayerDB.FindPlayers( ip );

            } else if( name.Equals( "*" ) ) {
                infos = (PlayerInfo[])PlayerDB.PlayerInfoList.Clone();

            } else if( name.Contains( "*" ) || name.Contains( "?" ) ) {
                // find players by regex/wildcard
                string regexString = "^" + RegexNonNameChars.Replace( name, "" ).Replace( "*", ".*" ).Replace( "?", "." ) + "$";
                Regex regex = new Regex( regexString, RegexOptions.IgnoreCase | RegexOptions.Compiled );
                infos = PlayerDB.FindPlayers( regex );

            } else if( name.StartsWith( "@" ) ) {
                string rankName = name.Substring( 1 );
                Rank rank = RankManager.FindRank( rankName );
                if( rank == null ) {
                    player.MessageNoRank( rankName );
                    return;
                } else {
                    infos = PlayerDB.PlayerInfoList
                                    .Where( info => info.Rank == rank )
                                    .ToArray();
                }

            } else if( name.StartsWith( "!" ) ) {
                // find online players by partial matches
                name = name.Substring( 1 );
                infos = Server.FindPlayers( name, true )
                              .Select( p => p.Info )
                              .ToArray();

            } else {
                // find players by partial matching
                PlayerInfo tempInfo;
                if( !PlayerDB.FindPlayerInfo( name, out tempInfo ) ) {
                    infos = PlayerDB.FindPlayers( name );
                } else if( tempInfo == null ) {
                    player.MessageNoPlayer( name );
                    return;
                } else {
                    infos = new[] { tempInfo };
                }
            }

            Array.Sort( infos, new PlayerInfoComparer( player ) );

            if( infos.Length == 1 ) {
                // only one match found; print it right away
                player.LastUsedPlayerName = infos[0].Name;
                PrintPlayerInfo( player, infos[0] );

            } else if( infos.Length > 1 ) {
                // multiple matches found
                if( infos.Length <= PlayersPerPage ) {
                    // all fit to one page
                    player.MessageManyMatches( "player", infos );

                } else {
                    // pagination
                    int offset;
                    if( !cmd.NextInt( out offset ) ) offset = 0;
                    if( offset >= infos.Length ) {
                        offset = Math.Max( 0, infos.Length - PlayersPerPage );
                    }
                    PlayerInfo[] infosPart = infos.Skip( offset ).Take( PlayersPerPage ).ToArray();
                    player.MessageManyMatches( "player", infosPart );
                    if( offset + infosPart.Length < infos.Length ) {
                        // normal page
                        player.Message( "Showing {0}-{1} (out of {2}). Next: &H/Info {3} {4}",
                                        offset + 1, offset + infosPart.Length, infos.Length,
                                        name, offset + infosPart.Length );
                    } else {
                        // last page
                        player.Message( "Showing matches {0}-{1} (out of {2}).",
                                        offset + 1, offset + infosPart.Length, infos.Length );
                    }
                }

            } else {
                // no matches found
                player.MessageNoPlayer( name );
            }
        }
Exemple #51
0
        static BlockDBUndoArgs ParseBlockDBUndoParams( Player player, CommandReader cmd, string cmdName, bool not ) {
            // check if command's being called by a worldless player (e.g. console)
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );

            // ensure that BlockDB is enabled
            if( !BlockDB.IsEnabledGlobally ) {
                player.Message( "&W{0}: BlockDB is disabled on this server.", cmdName );
                return null;
            }
            if( !playerWorld.BlockDB.IsEnabled ) {
                player.Message( "&W{0}: BlockDB is disabled in this world.", cmdName );
                return null;
            }

            // parse the first parameter - either numeric or time limit
            string range = cmd.Next();
            if( range == null ) {
                CdUndoPlayer.PrintUsage( player );
                return null;
            }
            int countLimit;
            TimeSpan ageLimit = TimeSpan.Zero;
            if( !Int32.TryParse( range, out countLimit ) && !range.TryParseMiniTimeSpan( out ageLimit ) ) {
                player.Message( "{0}: First parameter should be a number or a timespan.", cmdName );
                return null;
            }
            if( ageLimit > DateTimeUtil.MaxTimeSpan ) {
                player.MessageMaxTimeSpan();
                return null;
            }

            // parse second and consequent parameters (player names)
            HashSet<PlayerInfo> targets = new HashSet<PlayerInfo>();
            bool allPlayers = false;
            while( true ) {
                string name = cmd.Next();
                if( name == null ) {
                    break;
                } else if( name == "*" ) {
                    // all players
                    if( not ) {
                        player.Message( "{0}: \"*\" not allowed (cannot undo \"everyone except everyone\")", cmdName );
                        return null;
                    }
                    if( allPlayers ) {
                        player.Message( "{0}: \"*\" was listed twice.", cmdName );
                        return null;
                    }
                    allPlayers = true;

                } else {
                    // individual player
                    PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, name, SearchOptions.IncludeSelf );
                    if( target == null ) {
                        return null;
                    }
                    if( targets.Contains( target ) ) {
                        player.Message( "{0}: Player {1}&S was listed twice.",
                                        target.ClassyName, cmdName );
                        return null;
                    }
                    // make sure player has the permission
                    if( !not &&
                        player.Info != target && !player.Can( Permission.UndoAll ) &&
                        !player.Can( Permission.UndoOthersActions, target.Rank ) ) {
                        player.Message( "&W{0}: You may only undo actions of players ranked {1}&S or lower.",
                                        cmdName,
                                        player.Info.Rank.GetLimit( Permission.UndoOthersActions ).ClassyName );
                        player.Message( "Player {0}&S is ranked {1}",
                                        target.ClassyName, target.Rank.ClassyName );
                        return null;
                    }
                    targets.Add( target );
                }
            }
            if( targets.Count == 0 && !allPlayers ) {
                player.Message( "{0}: Specify at least one player name, or \"*\" to undo everyone.", cmdName );
                return null;
            }
            if( targets.Count > 0 && allPlayers ) {
                player.Message( "{0}: Cannot mix player names and \"*\".", cmdName );
                return null;
            }

            // undoing everyone ('*' in place of player name) requires UndoAll permission
            if( ( not || allPlayers ) && !player.Can( Permission.UndoAll ) ) {
                player.MessageNoAccess( Permission.UndoAll );
                return null;
            }

            // Queue UndoPlayerCallback to run
            return new BlockDBUndoArgs {
                Player = player,
                AgeLimit = ageLimit,
                CountLimit = countLimit,
                Area = player.WorldMap.Bounds,
                World = playerWorld,
                Targets = targets.ToArray(),
                Not = not
            };
        }
Exemple #52
0
        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 );
                }
            }
        }
Exemple #53
0
        static void BanInfoHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( cmd.HasNext ) {
                CdBanInfo.PrintUsage( player );
                return;
            }

            IPAddress address;
            PlayerInfo info = null;

            if( name == null ) {
                name = player.Name;
            } else if( !player.Can( Permission.ViewOthersInfo ) ) {
                player.MessageNoAccess( Permission.ViewOthersInfo );
                return;
            }

            if( IPAddressUtil.IsIP( name ) && IPAddress.TryParse( name, out address ) ) {
                IPBanInfo banInfo = IPBanList.Get( address );
                if( banInfo != null ) {
                    player.Message( "{0} was banned by {1}&S on {2:dd MMM yyyy} ({3} ago)",
                                    banInfo.Address,
                                    banInfo.BannedByClassy,
                                    banInfo.BanDate,
                                    banInfo.TimeSinceLastAttempt );
                    if( !String.IsNullOrEmpty( banInfo.PlayerName ) ) {
                        player.Message( "  Banned by association with {0}",
                                        banInfo.PlayerNameClassy );
                    }
                    if( banInfo.Attempts > 0 ) {
                        player.Message( "  There have been {0} attempts to log in, most recently {1} ago by {2}",
                                        banInfo.Attempts,
                                        banInfo.TimeSinceLastAttempt.ToMiniString(),
                                        banInfo.LastAttemptNameClassy );
                    }
                    if( banInfo.BanReason != null ) {
                        player.Message( "  Ban reason: {0}", banInfo.BanReason );
                    }
                } else {
                    player.Message( "{0} is currently NOT banned.", address );
                }

            } else {
                info = PlayerDB.FindPlayerInfoOrPrintMatches( player, name );
                if( info == null ) return;

                address = info.LastIP;

                IPBanInfo ipBan = IPBanList.Get( info.LastIP );
                switch( info.BanStatus ) {
                    case BanStatus.Banned:
                        if( ipBan != null ) {
                            player.Message( "Player {0}&S and their IP are &CBANNED", info.ClassyName );
                        } else {
                            player.Message( "Player {0}&S is &CBANNED&S (but their IP is not).", info.ClassyName );
                        }
                        break;
                    case BanStatus.IPBanExempt:
                        if( ipBan != null ) {
                            player.Message( "Player {0}&S is exempt from an existing IP ban.", info.ClassyName );
                        } else {
                            player.Message( "Player {0}&S is exempt from IP bans.", info.ClassyName );
                        }
                        break;
                    case BanStatus.NotBanned:
                        if( ipBan != null ) {
                            player.Message( "Player {0}&s is not banned, but their IP is.", info.ClassyName );
                        } else {
                            player.Message( "Player {0}&s is not banned.", info.ClassyName );
                        }
                        break;
                }

                if( info.BanDate != DateTime.MinValue ) {
                    player.Message( "  Last ban by {0}&S on {1:dd MMM yyyy} ({2} ago).",
                                    info.BannedByClassy,
                                    info.BanDate,
                                    info.TimeSinceBan.ToMiniString() );
                    if( info.BanReason != null ) {
                        player.Message( "  Last ban reason: {0}", info.BanReason );
                    }
                } else {
                    player.Message( "No past bans on record." );
                }

                if( info.UnbanDate != DateTime.MinValue && !info.IsBanned ) {
                    player.Message( "  Unbanned by {0}&S on {1:dd MMM yyyy} ({2} ago).",
                                    info.UnbannedByClassy,
                                    info.UnbanDate,
                                    info.TimeSinceUnban.ToMiniString() );
                    if( info.UnbanReason != null ) {
                        player.Message( "  Last unban reason: {0}", info.UnbanReason );
                    }
                }

                if( info.BanDate != DateTime.MinValue ) {
                    TimeSpan banDuration;
                    if( info.IsBanned ) {
                        banDuration = info.TimeSinceBan;
                        player.Message( "  Ban duration: {0} so far",
                                        banDuration.ToMiniString() );
                    } else {
                        banDuration = info.UnbanDate.Subtract( info.BanDate );
                        player.Message( "  Previous ban's duration: {0}",
                                        banDuration.ToMiniString() );
                    }
                }
            }

            // Show alts
            if( !address.Equals( IPAddress.None ) ) {
                List<PlayerInfo> altNames = new List<PlayerInfo>();
                int bannedAltCount = 0;
                foreach( PlayerInfo playerFromSameIP in PlayerDB.FindPlayers( address ) ) {
                    if( playerFromSameIP == info ) continue;
                    altNames.Add( playerFromSameIP );
                    if( playerFromSameIP.IsBanned ) {
                        bannedAltCount++;
                    }
                }

                if( altNames.Count > 0 ) {
                    altNames.Sort( new PlayerInfoComparer( player ) );
                    if( altNames.Count > MaxAltsToPrint ) {
                        if( bannedAltCount > 0 ) {
                            player.MessagePrefixed( "&S  ",
                                                    "&S  Over {0} accounts ({1} banned) on IP: {2} &Setc",
                                                    MaxAltsToPrint,
                                                    bannedAltCount,
                                                    altNames.Take( 15 ).ToArray().JoinToClassyString() );
                        } else {
                            player.MessagePrefixed( "&S  ",
                                                    "&S  Over {0} accounts on IP: {1} &Setc",
                                                    MaxAltsToPrint,
                                                    altNames.Take( 15 ).ToArray().JoinToClassyString() );
                        }
                    } else {
                        if( bannedAltCount > 0 ) {
                            player.MessagePrefixed( "&S  ",
                                                    "&S  {0} accounts ({1} banned) on IP: {2}",
                                                    altNames.Count,
                                                    bannedAltCount,
                                                    altNames.ToArray().JoinToClassyString() );
                        } else {
                            player.MessagePrefixed( "&S  ",
                                                    "&S  {0} accounts on IP: {1}",
                                                    altNames.Count,
                                                    altNames.ToArray().JoinToClassyString() );
                        }
                    }
                }
            }
        }
Exemple #54
0
        static void WhereHandler( Player player, CommandReader cmd ) {
            string name = cmd.Next();
            if( cmd.HasNext ) {
                CdWhere.PrintUsage( player );
                return;
            }
            Player target = player;

            if( name != null ) {
                if( !player.Can( Permission.ViewOthersInfo ) ) {
                    player.MessageNoAccess( Permission.ViewOthersInfo );
                    return;
                }
                target = Server.FindPlayerOrPrintMatches( player, name, false, true );
                if( target == null ) return;
            } else if( target.World == null ) {
                player.Message( "When called from console, &H/Where&S requires a player name." );
                return;
            }

            if( target.World == null ) {
                // Chances of this happening are miniscule
                player.Message( "Player {0}&S is not in any world.", target.Name );
                return;
            } else {
                player.Message( "Player {0}&S is on world {1}&S:",
                                target.ClassyName,
                                target.World.ClassyName );
            }

            Vector3I targetBlockCoords = target.Position.ToBlockCoords();
            player.Message( "{0}{1} - {2}",
                            Color.Silver,
                            targetBlockCoords,
                            GetCompassString( target.Position.R ) );
        }
Exemple #55
0
        static void ColorsHandler( Player player, CommandReader cmd ) {
            if( cmd.HasNext ) {
                CdColors.PrintUsage( player );
                return;
            }
            StringBuilder sb = new StringBuilder( "List of colors: " );

            foreach( var color in Color.ColorNames ) {
                sb.AppendFormat( "&{0}%{0} {1} ", color.Key, color.Value );
            }

            player.Message( sb.ToString() );
            if( !player.Can( Permission.UseColorCodes ) ) {
                Rank reqRank = RankManager.GetMinRankWithAllPermissions( Permission.UseColorCodes );
                if( reqRank == null ) {
                    player.Message( "&SNone of the ranks have permission to use colors in chat." );
                } else {
                    player.Message( "&SOnly {0}+&S can use colors in chat.",
                             reqRank.ClassyName );
                }
            }
        }
Exemple #56
0
        static void PossessHandler( Player player, Command cmd )
        {
            string targetName = cmd.Next();
            if ( targetName == null ) {
                CdPossess.PrintUsage( player );
                return;
            }
            Player target = Server.FindPlayerOrPrintMatches( player, targetName, false, true );
            if ( target == null ) return;
            if ( target.Immortal ) {
                player.Message( "You cannot possess {0}&S, they are immortal", target.ClassyName );
                return;
            }
            if ( target == player ) {
                player.Message( "You cannot possess yourself." );
                return;
            }

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

            if ( !player.Possess( target ) ) {
                player.Message( "Already possessing {0}", target.ClassyName );
            }
        }
Exemple #57
0
        static void SetSpawnHandler( Player player, CommandReader cmd ) {
            World playerWorld = player.World;
            if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );


            string playerName = cmd.Next();
            if( playerName == null ) {
                Map map = player.WorldMap;
                map.Spawn = player.Position;
                player.TeleportTo( map.Spawn );
                player.Send( Packet.MakeAddEntity( Packet.SelfID, player.ListName, player.Position ) );
                player.Message( "New spawn point saved." );
                Logger.Log( LogType.UserActivity,
                            "{0} changed the spawned point.",
                            player.Name );

            } else if( player.Can( Permission.Bring ) ) {
                Player[] infos = playerWorld.FindPlayers( player, playerName );
                if( infos.Length == 1 ) {
                    Player target = infos[0];
                    player.LastUsedPlayerName = target.Name;
                    if( player.Can( Permission.Bring, target.Info.Rank ) ) {
                        target.Send( Packet.MakeAddEntity( Packet.SelfID, target.ListName, player.Position ) );
                    } else {
                        player.Message( "You may only set spawn of 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 );
                    }

                } else if( infos.Length > 0 ) {
                    player.MessageManyMatches( "player", infos );

                } else {
                    infos = Server.FindPlayers( player, playerName, true, false, true );
                    if( infos.Length > 0 ) {
                        player.Message( "You may only set spawn of players on the same world as you." );
                    } else {
                        player.MessageNoPlayer( playerName );
                    }
                }
            } else {
                player.MessageNoAccess( CdSetSpawn );
            }
        }
Exemple #58
0
        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 );
            }
        }
Exemple #59
0
        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 );
            }
        }
Exemple #60
0
        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 );
                }
            }
        }