When a hotel chef disgruntled over a human-resources complaint came to work one day in August, he told a co-worker how he planned to retaliate: “Shoot up everyone in the hotel,” Long Beach, Calif., investigators said. Now, that man could spend nearly four years in prison for his threats.

Rodolfo Montoya, 37, of Huntington Beach pleaded no contest Monday to two felony charges of making criminal threats to the Marriott hotel near the Long Beach Airport; he faces sentencing on Jan. 27 in Los Angeles County.

Montoya initially pleaded not guilty when arrested in August on suspicion of manufacturing and distributing assault weapons, possession of an assault weapon and making criminal threats. By entering a no-contest plea, he avoids a trial in a case that drew headlines in the summer amid a slew of deadly shootings nationwide.

Michael Ferrante, Montoya’s public defender, was not immediately available for comment.

Police credited Montoya’s co-worker with helping avert a mass shooting by taking the Aug. 18 threat seriously and alerting authorities. When Montoya was arrested at his home the next day, police found a stockpile of tactical gear and firearms, including high-capacity magazines and an AR-15 rifle.

“In recent months, we have seen several tragic incidents that have resulted in many lives lost,” Long Beach Police Chief Robert G. Luna said at the time of Montoya’s arrest. “The witnesses who came forward and the diligence of our employees involved in this investigation very likely prevented a threat of violence and saved many lives.”

According to a 2014 FBI study, a survey of 160 shootings between 2000 and 2013 found nearly half occurred in business settings that were open to the public, including office parks, shopping centers, restaurants and movie theaters.

According to the Los Angeles Times, Montoya had no prior criminal record that would have disqualified him for firearm purchases. The Los Angeles County District Attorney’s Office confirmed to The Washington Post that all of the weapons were legally purchased and that the AR-15 was purchased before the state’s ban on assault-style weapons and modified to comply with the new law.

California was among the states to experience a mass shooting last year when a 19-year-old man opened fire at the Gilroy Garlic Festival outside San Jose and killed three people, including two children.

Read more: