Two teenagers were each jailed for nine years after robbing a man in his own home.
Yahya Benkhelifa and Zakariya Etarghi had first assaulted the victim when he had refused to let his flat be used for drug dealing, Leicester Crown Court was told.
Eight days later the pair launched another vicious attack on the man before robbing him.
The first attack happened when the pair burst into the man's home in Highfields, Leicester, on May 1.
They punched him to his face and body and he fell to the ground. Etarghi then hit the man with a candlestick, before the spike from the candlestick was stuck into the victim's foot.
The pair returned on May 9, with two other men, and convinced the man, a drug user, to let them in again.
Prosecuting, James Bide-Thomas, said: "Mr Benkhelifa slapped him to the face and Mr Etarghi picked up a broom handle.
"Mr Etarghi picked up a large piece of wood which had been part of a cupboard and used it as a weapon."
Items were taken from the house, but no further details were given in court.
The victim crawled into a lift and was able to find a security guard.
He was taken to Leicester Royal Infirmary where he received nine stitches to his head and arms.
Benkhelifa was also caught dealing drugs to an undercover officer called "Tommy" in February, in Operation Nutmeg.
Mr Bide-Thomas said: "Tommy was standing in Granby Street pretending to use a public telephone when he was approached by someone called Danny, who he knew as a drug user."
Danny offered to put him in touch with a man he called Alfred – who was Benkhelifa – who supplied Danny with heroin to give to the officer.
The policeman, undercover as part of the police operation, bought heroin from Benkhelifa directly on three more occasions, and crack cocaine once, throughout February and March.
Mr Bide-Thomas said on March 13, the undercover officer tried to call Benkhelifa and got no answer, but later received a text message saying, "I'm on now," and the pair met in Derwent Street, Spinney Hills.
He said: "They had a conversation and it was effectively stated that were he to find other people that might be interested in purchasing heroin, then he could get a discount on future purchases."
Mr Bide-Thomas said Etarghi faced eight counts of possession with intent to supply, which were of a similar "street dealing" nature.
The court did not hear specific details of these exchanges.
Both pleaded guilty to assault occasioning actual bodily harm and robbery.
Benkhelifa (19), of Park Vale Road, Spinney Hills, Leicester pleaded guilty to five counts of possession of drugs with intent to supply and Etarghi (18), of no fixed abode, pleaded guilty to eight counts.
In mitigation, Donald Lawler said Benkhelifa had no previous convictions, and had begun taking drugs, and then selling them to pay off debts.
"He was sucked into the offending pattern," he said.
Mr Lawler said Etarghi had since voluntarily enrolled on anger management courses and was studying in prison.
Judge Michael Pert QC sentenced the pair to nine years each for the robbery, and eight months each for the assault.
He sentenced Benkhelifa to two years for the drugs charges, and Etarghi to three years. The sentences will run concurrently.
Judge Pert said: "Robbery is a very serious offence. To attack someone in their home and rob them is a despicable thing."