Kyle Gregg was spotted by CCTV operators in the town centre on February 15, 17 and 19, despite being banned from entering it following a criminal behaviour order, which was imposed in April, last year.
On the last occasion he was sitting on a bench outside the library and under the influence of mamba, said prosecutor Donna Fawcett.
A small quantity of the drug was also found on him at the police station, she added.
David Grant, mitigating, said: “He finds it more comfortable temperature-wise to be in the town centre.
“His self-harming is becoming more concerning to everyone.
“He says “When I am cold and I am hungry and I know where the food bank is, I am not going to walk 40 minutes when I can walk for two minutes.””
Mr Grant said the original order was imposed to keep Gregg out of the town centre’s shops.
Gregg, 30, admitted four breaches of the criminal behaviour order and possession of the Class B drug, when he appeared at Mansfield Magistrates Court, on Wednesday.
District judge Jonathan Taaffe handed Gregg a 36 week prison sentence.
“Use this time constructively,” he advised. “Liaise with Mr Grant.
“It may well be this order can be looked at to simply include the shops in the town centre.”
Gregg was ordered to pay a £115 government surcharge.