fCraft.StandardCommands.DoIPBan C# (CSharp) Method

DoIPBan() private method

private DoIPBan ( Player player, IPAddress address, string reason, string playerName, bool banAll, bool unban ) : void
player Player
address System.Net.IPAddress
reason string
playerName string
banAll bool
unban bool
return void
        void DoIPBan( Player player, IPAddress address, string reason, string playerName, bool banAll, bool unban ) {
            Player other;
            if( unban ) {
                if( world.bans.Remove( address ) ) {
                    player.Message( address.ToString() + " has been removed from the IP ban list." );
                } else {
                    player.Message( address.ToString() + " is not currently banned." );
                }
                if( banAll ) {
                    foreach( PlayerInfo otherInfo in world.db.FindPlayersByIP( address ) ) {
                        if( otherInfo.ProcessUnBan( player.name, reason + "~UnBanAll" ) ) {
                            player.Message( otherInfo.name + " matched the IP and was also unbanned." );
                        }
                    }
                }

            } else {
                if( world.bans.Add( new IPBanInfo( address, playerName, player.name, reason ) ) ) {
                    player.Message( address.ToString() + " has been added to the IP ban list." );

                } else {
                    player.Message( address.ToString() + " is already banned." );
                }
                foreach( PlayerInfo otherInfo in world.db.FindPlayersByIP( address ) ) {
                    if( banAll && otherInfo.ProcessBan( player.name, reason + "~BanAll" ) ) {
                        player.Message( otherInfo.name + " matched the IP and was also banned." );
                    }
                    other = world.FindPlayerExact( otherInfo.name );
                    if( other != null ) {
                        other.session.Kick( "Your IP was just banned by " + player.name );
                    }
                }
            }
        }