A prisoner told a judge the only way to protect his sobriety from drug dealers and users in prison was to assault a guard and be sent to punitive detention.