Avoid checking entity spawns during shutdown.

For whatever reason, during a shutdown a plugin may have custom data
that causes Sponge to trigger spawn events. To avoid issues, we ignore
all spawns during shutdown.
This commit is contained in:
bloodshot 2020-01-09 20:12:58 -05:00
parent a170a5cef0
commit 95a7420d66

View File

@ -91,6 +91,7 @@
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.explosion.Explosion;
import org.spongepowered.api.world.storage.WorldProperties;
import org.spongepowered.common.SpongeImpl;
import java.time.Instant;
import java.util.Iterator;
@ -274,6 +275,11 @@ public void onEntityConstruct(ConstructEntityEvent.Pre event, @Root Object sourc
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntitySpawn(SpawnEntityEvent event) {
// For whatever reason, some custom data seems to be triggering spawn events during shutdown
if (!SpongeImpl.getServer().isServerRunning()) {
return;
}
Object source = event.getSource();
if (source instanceof ConsoleSource || !GDFlags.ENTITY_SPAWN || event.getEntities().isEmpty()) {
return;