First, he posted compromising images of his girlfriend on her own Facebook account when she started to ignore him.
Then, after police got the help of his 18-year-old girlfriend to arrest him, he slashed an officer on the arm.
Yesterday, the 25-year-old cook, who cannot be named due to a gag order to protect the teenager's identity, was jailed for six years and two months with six strokes of the cane.
He pleaded guilty to nine charges, which included drug consumption and cheating.
The teen had shared the passwords to her Facebook account and e-mail with the man.
But after the couple quarrelled in March last year, he logged into her Facebook account and posted photos of her naked and even a video of her undressing.
Worried that more compromising photos or videos in his possession would be circulated, the teen made a police report on March 10.
Officers then enlisted her help to arrange a meeting with the man.
That same evening, Station Inspector Jimmy Tan Thiam Soon, 43, and his two colleagues, dressed in plain clothes, arrived outside the teen's home in Geylang.
She then sent her boyfriend a text message to meet her downstairs.
Before leaving his home, the man saw someone looking through the glass panel of the door.
He tucked a bread knife with a 21cm blade in his shorts.
When the man left his home, Station Insp Tan moved quickly towards him.
At the same time, his two colleagues rushed out of the staircase landing and shouted "Police".
Before Station Insp Tan could identify himself as an officer, the man slashed him on the right bicep, causing an 8cm cut.
The officers then disarmed the man and arrested him.
In mitigation for a lighter sentence, the man's lawyers, Mr Josephus Tan and Mr Cory Wong, said their client - who was convicted of having underage sex with a girl and has been in army detention for drug consumption - did not know that the man he slashed was a policeman.
Mr Wong said his client hopes to restart his food and beverage business upon his release from prison.