AUGUSTA — Dealing crack cocaine and heroin in Augusta cost an apologetic ex-New Yorker six years in Maine prison.

Allen Jamel James, 32, formerly of Manhattan, pleaded guilty Thursday in Kennebec County Superior Court to four counts of aggravated trafficking, two each in cocaine and two in heroin, that occurred June 4 and 5, 2013, in parking lots on Mount Vernon Avenue and Crossing Way.

The prosecutor said James sold the drugs to an undercover investigator working for the Maine Drug Enforcement Agency who was wearing a wire and recorded the events.

James, who uses the alias “Bones,” told Justice Donald Marden that he moved from New York City to Maine in 2010 “because of my addiction” and obtained seasonal work at first; but things went badly when he couldn’t find another job and couldn’t pay his bills, so he returned to getting high.

“I gave up on everything,” he said. “I was destroying families and mine.”

He told the judge he has lost his two children, now ages 2 and 5, who are now in the custody of the Maine Department of Health and Human Services, and that he’s been seeking help for his substance abuse problems in jail.

“I would like to apologize to the people I hurt, the MDEA, the deputies … and my two kids, who have given up on me,” James said, reading a letter he had written prior to the hearing.

Marden told him, “Defendants who sell drugs are really selling misery to the lives of these people.”

Marden imposed the six-year prison term jointly recommended by the prosecutor, Assistant Attorney General Katie Sibley and James’ attorney, Ronald Bourget.

James also pleaded guilty to a charges of resisting arrest, which involved a scuffle with deputies in the back of same courtroom on July 19, 2013.

Sibley said James was sitting with other people watching a hearing when deputies went to arrest him and he refused to cooperate.

James has prior drug convictions in New York and in Connecticut, Sibley said, in support of the six-year term.

James also was fined $1,600 for the Maine drug offenses.

Another defendant, Star Black, 22, of Gardiner, pleaded guilty to a related charge of unlawful possession of heroin.

Sibley said undercover agents had James under surveillance and expected him to arrive when instead Black brought the heroin to them on June 18, 2013 in a parking lot on Mount Vernon Avenue.

Black told the judge that James and his brother were staying at her apartment in Augusta at the invitation of one of her roommates and that James told her to make the delivery.

She said James threatened to hurt her and her child.

Black was sentenced to 18 months in prison, all suspended, and one year of probation. She was fined $400.

Her attorney, Stephen Bourget, said Black has worked to distance herself from the drug trade, her former apartment, and had entered substance abuse counseling voluntarily.

Several other people were sentenced this week in separate hearings in Kennebec County Superior Court:

• Howard H. Barrows, 61, of Belgrade, operating under the influence Dec. 21, 1997; $500 fine, 90-day license suspension.

• Zachary J. Erkson, 24, of Phillips, theft by unauthorized taking or transfer, refusing to submit to arrest or detention, refusing to stop April 2, in Waterville; 16-month prison sentence.

• Dede Reynolds Kasevich, 45, of Benton, operating after habitual-offender revocation Sept. 17, 2013, in Waterville; one-year jail sentence, $1,000 fine.

• Richard Wesley McMillan Sr., 56, of Windsor, operating under the influence Dec. 21, 2013, in China; 10-day jail sentence, $700 fine, 150-day license suspension.

• Anthony Perkins, 27, of Waterville, criminal mischief and assault Sept. 8, 2013, in Waterville; 60-day jail sentence, $300 fine.

• Daniel P. Stump, 29, of West Gardiner, unlawful possession of scheduled drugs Jan. 14 in Farmingdale; $400 fine.