Ejemplo n.º 1
0
        static void ZoneAddCallback(Player player, Vector3I[] marks, object tag)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            if (!player.Info.Rank.AllowSecurityCircumvention)
            {
                SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info);
                switch (buildCheck)
                {
                case SecurityCheckResult.BlackListed:
                    player.Message("Cannot add zones to world {0}&S: You are barred from building here.",
                                   playerWorld.ClassyName);
                    return;

                case SecurityCheckResult.RankTooLow:
                    player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.",
                                   playerWorld.ClassyName);
                    return;
                    //case SecurityCheckResult.RankTooHigh:
                }
            }

            Zone zone  = (Zone)tag;
            var  zones = player.WorldMap.Zones;

            lock (zones.SyncRoot) {
                Zone dupeZone = zones.FindExact(zone.Name);
                if (dupeZone != null)
                {
                    player.Message("A zone named \"{0}\" has just been created by {1}",
                                   dupeZone.Name, dupeZone.CreatedBy);
                    return;
                }

                zone.Create(new BoundingBox(marks[0], marks[1]), player.Info);

                player.Message("Zone \"{0}\" created, {1} blocks total.",
                               zone.Name, zone.Bounds.Volume);
                Logger.Log(LogType.UserActivity,
                           "Player {0} created a new zone \"{1}\" containing {2} blocks.",
                           player.Name,
                           zone.Name,
                           zone.Bounds.Volume);

                zones.Add(zone);
            }
        }
Ejemplo n.º 2
0
        public override bool Prepare(Vector3I[] marks)
        {
            if (Player.World == null && !Player.IsSuper)
            {
                PlayerOpException.ThrowNoWorld(Player);
            }
            if (!base.Prepare(marks))
            {
                return(false);
            }

            BlocksTotalEstimate = Bounds.Volume;
            Coords = Bounds.MinVertex;

            Context |= BlockChangeContext.Cut;
            return(true);
        }
Ejemplo n.º 3
0
        public override bool Prepare(Vector3I[] marks)
        {
            if (Player.World == null)
            {
                PlayerOpException.ThrowNoWorld(Player);
            }
            if (!base.Prepare(marks))
            {
                return(false);
            }

            BlocksTotalEstimate = Bounds.Volume;
            Coords = Bounds.MinVertex;

            // remember dimensions and orientation
            CopyState copyInfo = new CopyState(marks[0], marks[1]);

            for (int x = Bounds.XMin; x <= Bounds.XMax; x++)
            {
                for (int y = Bounds.YMin; y <= Bounds.YMax; y++)
                {
                    for (int z = Bounds.ZMin; z <= Bounds.ZMax; z++)
                    {
                        copyInfo.Buffer[x - Bounds.XMin, y - Bounds.YMin, z - Bounds.ZMin] = Map.GetBlock(x, y, z);
                    }
                }
            }
            copyInfo.OriginWorld = Player.World.Name;
            copyInfo.CopyTime    = DateTime.UtcNow;
            Player.SetCopyInformation(copyInfo);

            Player.Message("{0} blocks cut into slot #{1}. You can now &H/Paste",
                           Bounds.Volume, Player.CopySlot + 1);
            Player.Message("Origin at {0} {1}{2} corner.",
                           (copyInfo.Orientation.X == 1 ? "bottom" : "top"),
                           (copyInfo.Orientation.Y == 1 ? "south" : "north"),
                           (copyInfo.Orientation.Z == 1 ? "east" : "west"));

            Context |= BlockChangeContext.Cut;
            return(true);
        }
Ejemplo n.º 4
0
        static void ZoneRenameHandler(Player player, Command cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            // make sure that both parameters are given
            string oldName = cmd.Next();
            string newName = cmd.Next();

            if (oldName == null || newName == null)
            {
                CdZoneRename.PrintUsage(player);
                return;
            }

            // make sure that the new name is valid
            if (!World.IsValidName(newName))
            {
                player.Message("\"{0}\" is not a valid zone name", newName);
                return;
            }

            // find the old zone
            var  zones   = player.WorldMap.Zones;
            Zone oldZone = zones.Find(oldName);

            if (oldZone == null)
            {
                player.MessageNoZone(oldName);
                return;
            }

            // Check if a zone with "newName" name already exists
            Zone newZone = zones.FindExact(newName);

            if (newZone != null && newZone != oldZone)
            {
                player.Message("A zone with the name \"{0}\" already exists.", newName);
                return;
            }

            // check if any change is needed
            string fullOldName = oldZone.Name;

            if (fullOldName == newName)
            {
                player.Message("The zone is already named \"{0}\"", fullOldName);
                return;
            }

            // actually rename the zone
            zones.Rename(oldZone, newName);

            // announce the rename
            playerWorld.Players.Message("&SZone \"{0}\" was renamed to \"{1}&S\" by {2}", 0,
                                        fullOldName, oldZone.ClassyName, player.ClassyName);
            Logger.Log(LogType.UserActivity,
                       "Player {0} renamed zone \"{1}\" to \"{2}\" on world {3}",
                       player.Name, fullOldName, newName, playerWorld.Name);
        }
Ejemplo n.º 5
0
        static void ZoneAddHandler(Player player, Command cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            string givenZoneName = cmd.Next();

            if (givenZoneName == null)
            {
                CdZoneAdd.PrintUsage(player);
                return;
            }

            if (!player.Info.Rank.AllowSecurityCircumvention)
            {
                SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info);
                switch (buildCheck)
                {
                case SecurityCheckResult.BlackListed:
                    player.Message("Cannot add zones to world {0}&S: You are barred from building here.",
                                   playerWorld.ClassyName);
                    return;

                case SecurityCheckResult.RankTooLow:
                    player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.",
                                   playerWorld.ClassyName);
                    return;
                    //case SecurityCheckResult.RankTooHigh:
                }
            }

            Zone           newZone        = new Zone();
            ZoneCollection zoneCollection = player.WorldMap.Zones;

            if (givenZoneName.StartsWith("+"))
            {
                // personal zone (/ZAdd +Name)
                givenZoneName = givenZoneName.Substring(1);

                // Find the target player
                PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, givenZoneName);
                if (info == null)
                {
                    return;
                }

                // Make sure that the name is not taken already.
                // If a zone named after the player already exists, try adding a number after the name (e.g. "Notch2")
                newZone.Name = info.Name;
                for (int i = 2; zoneCollection.Contains(newZone.Name); i++)
                {
                    newZone.Name = givenZoneName + i;
                }

                newZone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank;
                newZone.Controller.Include(info);
                player.Message("Zone: Creating a {0}+&S zone for player {1}&S.",
                               newZone.Controller.MinRank.ClassyName, info.ClassyName);
            }
            else
            {
                // Adding an ordinary, rank-restricted zone.
                if (!World.IsValidName(givenZoneName))
                {
                    player.Message("\"{0}\" is not a valid zone name", givenZoneName);
                    return;
                }

                if (zoneCollection.Contains(givenZoneName))
                {
                    player.Message("A zone with this name already exists. Use &H/ZEdit&S to edit.");
                    return;
                }

                newZone.Name = givenZoneName;

                string rankName = cmd.Next();
                if (rankName == null)
                {
                    player.Message("No rank was specified. See &H/Help zone");
                    return;
                }
                Rank minRank = RankManager.FindRank(rankName);

                if (minRank != null)
                {
                    string name;
                    while ((name = cmd.Next()) != null)
                    {
                        if (name.Length == 0)
                        {
                            continue;
                        }

                        if (name.ToLower().StartsWith("msg="))
                        {
                            newZone.Message = name.Substring(4) + " " + (cmd.NextAll() ?? "");
                            player.Message("Zone: Custom denied messaged changed to '" + newZone.Message + "'");
                            break;
                        }

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

                        if (name.StartsWith("+"))
                        {
                            newZone.Controller.Include(info);
                        }
                        else if (name.StartsWith("-"))
                        {
                            newZone.Controller.Exclude(info);
                        }
                    }

                    newZone.Controller.MinRank = minRank;
                }
                else
                {
                    player.MessageNoRank(rankName);
                    return;
                }
            }
            player.Message("Zone " + newZone.ClassyName + "&S: Place a block or type &H/Mark&S to use your location.");
            player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions);
        }
Ejemplo n.º 6
0
        /// <summary> Unbans given IP address and all accounts on that IP. Throws PlayerOpException on problems. </summary>
        /// <param name="targetAddress"> IP address that is being unbanned. </param>
        /// <param name="player"> Player who is unbanning. </param>
        /// <param name="reason"> Reason for unban. May be null or empty, if permitted by server configuration. </param>
        /// <param name="announce"> Whether unban should be publicly announced on the server. </param>
        /// <param name="raiseEvents"> Whether RemovingIPBan, RemovedIPBan, BanChanging, and BanChanged events should be raised. </param>
        public static void UnbanAll([NotNull] this IPAddress targetAddress, [NotNull] Player player, [CanBeNull] string reason,
                                    bool announce, bool raiseEvents)
        {
            if (targetAddress == null)
            {
                throw new ArgumentNullException("targetAddress");
            }
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (reason != null && reason.Trim().Length == 0)
            {
                reason = null;
            }

            if (!player.Can(Permission.Ban, Permission.BanIP, Permission.BanAll))
            {
                PlayerOpException.ThrowPermissionMissing(player, null, "unban-all",
                                                         Permission.Ban, Permission.BanIP, Permission.BanAll);
            }

            // Check if player is trying to unban self
            if (targetAddress.Equals(player.IP) && !player.IsSuper())
            {
                PlayerOpException.ThrowCannotTargetSelf(player, null, "unban-all");
            }

            // Check if a non-bannable address was given (0.0.0.0 or 255.255.255.255)
            if (targetAddress.Equals(IPAddress.None) || targetAddress.Equals(IPAddress.Any))
            {
                PlayerOpException.ThrowInvalidIP(player, null, targetAddress);
            }

            PlayerOpException.CheckBanReason(reason, player, null, true);
            bool somethingGotUnbanned = false;

            // Unban the IP
            if (Contains(targetAddress))
            {
                if (Remove(targetAddress, raiseEvents))
                {
                    Logger.Log(LogType.UserActivity,
                               "{0} unbanned {1} (UnbanAll {1}). Reason: {2}",
                               player.Name, targetAddress, reason ?? "");

                    // Announce unban on the server
                    if (announce)
                    {
                        var can = Server.Players.Can(Permission.ViewPlayerIPs);
                        can.Message("&W{0} was unbanned by {1}", 0, targetAddress, player.ClassyName);
                        var cant = Server.Players.Cant(Permission.ViewPlayerIPs);
                        cant.Message("&WAn IP was unbanned by {0}", 0, player.ClassyName);
                    }

                    somethingGotUnbanned = true;
                }
            }

            // Unban individual players
            PlayerInfo[] allPlayersOnIP = PlayerDB.FindPlayers(targetAddress);
            foreach (PlayerInfo targetAlt in allPlayersOnIP)
            {
                if (targetAlt.BanStatus != BanStatus.Banned)
                {
                    continue;
                }

                // Raise PlayerInfo.BanChanging event
                PlayerInfoBanChangingEventArgs e = new PlayerInfoBanChangingEventArgs(targetAlt, player, true, reason, announce);
                if (raiseEvents)
                {
                    PlayerInfo.RaiseBanChangingEvent(e);
                    if (e.Cancel)
                    {
                        continue;
                    }
                    reason = e.Reason;
                }

                // Do the ban
                if (targetAlt.ProcessUnban(player.Name, reason))
                {
                    if (raiseEvents)
                    {
                        PlayerInfo.RaiseBanChangedEvent(e);
                    }

                    // Log and announce ban
                    Logger.Log(LogType.UserActivity,
                               "{0} unbanned {1} (UnbanAll {2}). Reason: {3}",
                               player.Name, targetAlt.Name, targetAddress, reason ?? "");
                    if (announce)
                    {
                        Server.Message("&WPlayer {0}&W was unbanned by {1}&W (UnbanAll)",
                                       targetAlt.ClassyName, player.ClassyName);
                    }
                    somethingGotUnbanned = true;
                }
            }

            // If no one ended up getting unbanned, quit here
            if (!somethingGotUnbanned)
            {
                PlayerOpException.ThrowNoOneToUnban(player, null, targetAddress);
            }

            // Announce UnbanAll reason towards the end of all unbans
            if (announce && ConfigKey.AnnounceKickAndBanReasons.Enabled() && reason != null)
            {
                Server.Message("&WUnbanAll reason: {0}", reason);
            }
        }
Ejemplo n.º 7
0
        /// <summary> Bans given IP address and all accounts on that IP. All players from IP are kicked.
        /// Throws PlayerOpException on problems. </summary>
        /// <param name="targetAddress"> IP address that is being banned. </param>
        /// <param name="player"> Player who is banning. </param>
        /// <param name="reason"> Reason for ban. May be empty, if permitted by server configuration. </param>
        /// <param name="announce"> Whether ban should be publicly announced on the server. </param>
        /// <param name="raiseEvents"> Whether AddingIPBan, AddedIPBan, BanChanging, and BanChanged events should be raised. </param>
        public static void BanAll([NotNull] this IPAddress targetAddress, [NotNull] Player player, [CanBeNull] string reason,
                                  bool announce, bool raiseEvents)
        {
            if (targetAddress == null)
            {
                throw new ArgumentNullException("targetAddress");
            }
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (reason != null && reason.Trim().Length == 0)
            {
                reason = null;
            }

            if (!player.Can(Permission.Ban, Permission.BanIP, Permission.BanAll))
            {
                PlayerOpException.ThrowPermissionMissing(player, null, "ban-all",
                                                         Permission.Ban, Permission.BanIP, Permission.BanAll);
            }

            // Check if player is trying to ban self
            if (targetAddress.Equals(player.IP) && !player.IsSuper())
            {
                PlayerOpException.ThrowCannotTargetSelf(player, null, "ban-all");
            }

            // Check if a non-bannable address was given (0.0.0.0 or 255.255.255.255)
            if (targetAddress.Equals(IPAddress.None) || targetAddress.Equals(IPAddress.Any))
            {
                PlayerOpException.ThrowInvalidIP(player, null, targetAddress);
            }

            // Check if any high-ranked players use this address
            PlayerInfo[] allPlayersOnIP        = PlayerDB.FindPlayers(targetAddress);
            PlayerInfo   infoWhomPlayerCantBan = allPlayersOnIP.FirstOrDefault(info => !player.Can(Permission.Ban, info.Rank));

            if (infoWhomPlayerCantBan != null)
            {
                PlayerOpException.ThrowPermissionLimitIP(player, infoWhomPlayerCantBan, targetAddress);
            }

            PlayerOpException.CheckBanReason(reason, player, null, false);
            bool somethingGotBanned = false;

            // Ban the IP
            if (!Contains(targetAddress))
            {
                IPBanInfo banInfo = new IPBanInfo(targetAddress, null, player.Name, reason);
                if (Add(banInfo, raiseEvents))
                {
                    Logger.Log(LogType.UserActivity,
                               "{0} banned {1} (BanAll {1}). Reason: {2}",
                               player.Name, targetAddress, reason ?? "");

                    // Announce ban on the server
                    if (announce)
                    {
                        var can = Server.Players.Can(Permission.ViewPlayerIPs);
                        can.Message("&W{0} was banned by {1}", MessageType.Announcement, targetAddress, player.ClassyName);
                        var cant = Server.Players.Cant(Permission.ViewPlayerIPs);
                        cant.Message("&WAn IP was banned by {0}", MessageType.Announcement, player.ClassyName);
                    }
                    somethingGotBanned = true;
                }
            }

            // Ban individual players
            foreach (PlayerInfo targetAlt in allPlayersOnIP)
            {
                if (targetAlt.BanStatus != BanStatus.NotBanned)
                {
                    continue;
                }

                // Raise PlayerInfo.BanChanging event
                PlayerInfoBanChangingEventArgs e = new PlayerInfoBanChangingEventArgs(targetAlt, player, false, reason, announce);
                if (raiseEvents)
                {
                    PlayerInfo.RaiseBanChangingEvent(e);
                    if (e.Cancel)
                    {
                        continue;
                    }
                    reason = e.Reason;
                }

                // Do the ban
                if (targetAlt.ProcessBan(player, player.Name, reason))
                {
                    if (raiseEvents)
                    {
                        PlayerInfo.RaiseBanChangedEvent(e);
                    }

                    // Log and announce ban
                    Logger.Log(LogType.UserActivity,
                               "{0} banned {1} (BanAll {2}). Reason: {3}",
                               player.Name, targetAlt.Name, targetAddress, reason ?? "");
                    if (announce)
                    {
                        Server.Message("&WPlayer {0}&W was banned by {1}&W (BanAll)",
                                       targetAlt.ClassyName, player.ClassyName);
                    }
                    somethingGotBanned = true;
                }
            }

            // If no one ended up getting banned, quit here
            if (!somethingGotBanned)
            {
                PlayerOpException.ThrowNoOneToBan(player, null, targetAddress);
            }

            // Announce BanAll reason towards the end of all bans
            if (announce && ConfigKey.AnnounceKickAndBanReasons.Enabled() && reason != null)
            {
                Server.Message("&WBanAll reason: {0}", reason);
            }

            // Kick all players from IP
            Player[] targetsOnline = Server.Players.FromIP(targetAddress).ToArray();
            if (targetsOnline.Length <= 0)
            {
                return;
            }
            var kickReason = reason != null ? $"Banned by {player.Name}: {reason}" : $"Banned by {player.Name}";

            foreach (var t in targetsOnline)
            {
                t.Kick(kickReason, LeaveReason.BanAll);
            }
        }
Ejemplo n.º 8
0
        /// <summary> Unbans an IP address. If an associated PlayerInfo is known,
        /// use a different overload of this method instead. Throws PlayerOpException on problems. </summary>
        /// <param name="targetAddress"> IP address that is being unbanned. </param>
        /// <param name="player"> Player who is unbanning. </param>
        /// <param name="reason"> Reason for unban. May be empty, if permitted by server configuration. </param>
        /// <param name="announce"> Whether unban should be publicly announced on the server. </param>
        /// <param name="raiseEvents"> Whether RemovingIPBan and RemovedIPBan events should be raised. </param>
        public static void UnbanIP([NotNull] this IPAddress targetAddress, [NotNull] Player player, [CanBeNull] string reason,
                                   bool announce, bool raiseEvents)
        {
            if (targetAddress == null)
            {
                throw new ArgumentNullException("targetAddress");
            }
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (reason != null && reason.Trim().Length == 0)
            {
                reason = null;
            }

            // Check if player can unban IPs in general
            if (!player.Can(Permission.Ban, Permission.BanIP))
            {
                PlayerOpException.ThrowPermissionMissing(player, null, "IP-unban", Permission.Ban, Permission.BanIP);
            }

            // Check if a non-bannable address was given (0.0.0.0 or 255.255.255.255)
            if (targetAddress.Equals(IPAddress.None) || targetAddress.Equals(IPAddress.Any))
            {
                PlayerOpException.ThrowInvalidIP(player, null, targetAddress);
            }

            // Check if player is trying to unban self
            if (targetAddress.Equals(player.IP) && !player.IsSuper())
            {
                PlayerOpException.ThrowCannotTargetSelf(player, null, "IP-unban");
            }

            PlayerOpException.CheckBanReason(reason, player, null, true);

            // Actually unban
            bool result = Remove(targetAddress, raiseEvents);

            if (result)
            {
                Logger.Log(LogType.UserActivity,
                           "{0} unbanned {1} (UnbanIP {1}). Reason: {2}",
                           player.Name, targetAddress, reason ?? "");
                if (!announce)
                {
                    return;
                }
                var can = Server.Players.Can(Permission.ViewPlayerIPs);
                can.Message("&W{0} was unbanned by {1}", 0, targetAddress, player.ClassyName);
                var cant = Server.Players.Cant(Permission.ViewPlayerIPs);
                cant.Message("&WAn IP was unbanned by {0}", 0, player.ClassyName);
                if (ConfigKey.AnnounceKickAndBanReasons.Enabled() && reason != null)
                {
                    Server.Message("&WUnbanIP reason: {0}", reason);
                }
            }
            else
            {
                var msg = player.Can(Permission.ViewPlayerIPs)
                    ? $"IP address {targetAddress} is not currently banned."
                    : "Given IP address is not currently banned.";
                string colorMsg = "&S" + msg;
                throw new PlayerOpException(player, null, PlayerOpExceptionCode.NoActionNeeded, msg, colorMsg);
            }
        }
Ejemplo n.º 9
0
        /// <summary> Bans given IP address. All players from IP are kicked. If an associated PlayerInfo is known,
        /// use a different overload of this method instead. Throws PlayerOpException on problems. </summary>
        /// <param name="targetAddress"> IP address that is being banned. </param>
        /// <param name="player"> Player who is banning. </param>
        /// <param name="reason"> Reason for ban. May be empty, if permitted by server configuration. </param>
        /// <param name="announce"> Whether ban should be publicly announced on the server. </param>
        /// <param name="raiseEvents"> Whether AddingIPBan and AddedIPBan events should be raised. </param>
        public static void BanIP([NotNull] this IPAddress targetAddress, [NotNull] Player player, [CanBeNull] string reason,
                                 bool announce, bool raiseEvents)
        {
            if (targetAddress == null)
            {
                throw new ArgumentNullException("targetAddress");
            }
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (reason != null && reason.Trim().Length == 0)
            {
                reason = null;
            }

            // Check if player can ban IPs in general
            if (!player.Can(Permission.Ban, Permission.BanIP))
            {
                PlayerOpException.ThrowPermissionMissing(player, null, "IP-ban", Permission.Ban, Permission.BanIP);
            }

            // Check if a non-bannable address was given (0.0.0.0 or 255.255.255.255)
            if (targetAddress.Equals(IPAddress.None) || targetAddress.Equals(IPAddress.Any))
            {
                PlayerOpException.ThrowInvalidIP(player, null, targetAddress);
            }

            // Check if player is trying to ban self
            if (targetAddress.Equals(player.IP) && !player.IsSuper())
            {
                PlayerOpException.ThrowCannotTargetSelf(player, null, "IP-ban");
            }

            // Check if target is already banned
            IPBanInfo existingBan = Get(targetAddress);

            if (existingBan != null)
            {
                string msg;
                if (player.Can(Permission.ViewPlayerIPs))
                {
                    msg = String.Format("IP address {0} is already banned.", targetAddress);
                }
                else
                {
                    msg = String.Format("Given IP address is already banned.");
                }
                string colorMsg = "&S" + msg;
                throw new PlayerOpException(player, null, PlayerOpExceptionCode.NoActionNeeded, msg, colorMsg);
            }

            // Check if any high-ranked players use this address
            PlayerInfo infoWhomPlayerCantBan = PlayerDB.FindPlayers(targetAddress)
                                               .FirstOrDefault(info => !player.Can(Permission.Ban, info.Rank));

            if (infoWhomPlayerCantBan != null)
            {
                PlayerOpException.ThrowPermissionLimitIP(player, infoWhomPlayerCantBan, targetAddress);
            }

            PlayerOpException.CheckBanReason(reason, player, null, false);

            // Actually ban
            IPBanInfo banInfo = new IPBanInfo(targetAddress, null, player.Name, reason);
            bool      result  = Add(banInfo, raiseEvents);

            if (result)
            {
                Logger.Log(LogType.UserActivity,
                           "{0} banned {1} (BanIP {1}). Reason: {2}",
                           player.Name, targetAddress, reason ?? "");
                if (announce)
                {
                    // Announce ban on the server
                    var can = Server.Players.Can(Permission.ViewPlayerIPs);
                    can.Message("&W{0} was banned by {1}", 0, targetAddress, player.ClassyName);
                    var cant = Server.Players.Cant(Permission.ViewPlayerIPs);
                    cant.Message("&WAn IP was banned by {0}", 0, player.ClassyName);
                    if (ConfigKey.AnnounceKickAndBanReasons.Enabled() && reason != null)
                    {
                        Server.Message("&WBanIP reason: {0}", reason);
                    }
                }

                // Kick all players connected from address
                string kickReason;
                if (reason != null)
                {
                    kickReason = String.Format("IP-Banned by {0}: {1}", player.Name, reason);
                }
                else
                {
                    kickReason = String.Format("IP-Banned by {0}", player.Name);
                }
                foreach (Player other in Server.Players.FromIP(targetAddress))
                {
                    if (other.Info.BanStatus != BanStatus.IPBanExempt)
                    {
                        other.Kick(kickReason, LeaveReason.BanIP);   // TODO: check side effects of not using DoKick
                    }
                }
            }
            else
            {
                // address is already banned
                string msg;
                if (player.Can(Permission.ViewPlayerIPs))
                {
                    msg = String.Format("{0} is already banned.", targetAddress);
                }
                else
                {
                    msg = "Given IP address is already banned.";
                }
                string colorMsg = "&S" + msg;
                throw new PlayerOpException(player, null, PlayerOpExceptionCode.NoActionNeeded, msg, colorMsg);
            }
        }