Describe the solution you'd like
Just add two setting options to the configuration of Paper.
This feature can effectively prevent server latency caused by high CPU usage or high memory usage.
CreatureSpawnEvent
if (Bukkit.getTPS[0] <= 19.99)
{
event.setCancelled(true);
}
It is recommended to set a global variable, and then use timer timing to determine whether to turn on mob generation. When the system wants to generate mob, it only needs to judge this global variable.
A Plugin can easily achieve this by setting mob limits to 0 for however many ticks it wants based on the tps. However mob spawn lag usually only happens due to a bad config.
This is plugin territory. (Ab)use https://papermc.io/javadocs/paper/1.16/org/bukkit/World.html#setAnimalSpawnLimit-int-
Most helpful comment
CreatureSpawnEvent
if (Bukkit.getTPS[0] <= 19.99)
{
event.setCancelled(true);
}