/
Inactivity Scripts is a Paper Plugin that runs Commands/Scripts on four different events, when the server starts, when the server stops, and when the player count changes to 1 or 0.
You can decide if you want to set a breakpoint, that waits for your script to finish, this is recommended for the server stop, because the plugin being disabled at server stop might crash your Command/Script.
The plugin was only tested in 1.21.9 on Windows 11 and 1.21.11 on Debian 12 but should work with all 1.21 versions.

This plugin lets you run commands in console when the server is inactive.