Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical lags due to "Protections.MobSpawning: true" #53

Open
MrClean1337 opened this issue Apr 16, 2023 · 2 comments
Open

Critical lags due to "Protections.MobSpawning: true" #53

MrClean1337 opened this issue Apr 16, 2023 · 2 comments
Assignees

Comments

@MrClean1337
Copy link

Hello,

AFKPlus is causing huge lag if players are flying / running around in a farmworld.

This event causes huge lag:

@EventHandler
public void onNaturalMonsterSpawn(CreatureSpawnEvent e) {
if (!plugin.getConfig().getBoolean("Protections.MobSpawning"))
return;
//Return if it's not a monster or if it isn't natural
if (!(e.getEntity() instanceof Monster) || !e.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL))
return;
boolean shouldSpawn = spawnManager.shouldNaturalSpawn(e.getLocation());
if (!shouldSpawn)
e.setCancelled(true);
}

You can see this at my timings:
https://timings.aikar.co/dev/?id=8686e105aec34126a0175c0c93f17930#timings

I updated to git-Paper-513 (MC: 1.19.4) and to AFKPlus to 3.4.1 and then for some reason the server began to lag hugely.
If I switched the Protections.MobSpawning to false, the lag is gone.

@Dart2112
Copy link
Member

This is a known issue. All the plugin can do is cancel mob spawns, but when it does that the server just tries to spawn them again. This results in the plugin essentially fighting the server to stop it from spawning mobs. I'm keeping an eye out for a solution, but for now it's not an option that can be used on servers without the horsepower to keep up.

@Dart2112
Copy link
Member

Attached is a version that could be a little better, it's potentially more efficient at detecting if a mob should spawn or not. But the issue of the server continually trying to spawn the mobs will still exist
AFKPlus-Beta.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants