Skip to content

[Bug]: Mob spawning in mob-spawn=false zones after server restart #63

@derrickmehaffy

Description

@derrickmehaffy

Plugin Version

0.9.0

Operating System

Linux (Debian/Ubuntu)

Bug Description

Faction zones configured with mob-spawn = false correctly block mob spawning during the session, but after a server restart mobs spawn freely in these zones until a zone modification triggers reapplication.

Root cause — initialization race condition:

In WorldSetup.java:103-118, initializeSpawnSuppression() calls applySpawnSuppressionToAllWorlds() synchronously and immediately. However, ZoneManager.loadAll() (lines 138-181) loads zones asynchronously via CompletableFuture. At the time spawn suppression is applied, zoneManager.getAllZones() returns an empty collection because zones haven't finished loading yet.

The zone change callback (WorldSetup.java:109-114) IS wired to re-trigger suppression when zones are modified, which is why it works during a session. But on startup, the initial zone load completion doesn't trigger this callback — only explicit modifications do.

Key files:

  • WorldSetup.java (lines 103-118 — calls applySpawnSuppressionToAllWorlds() before zones load)
  • SpawnSuppressionManager.java (lines 127-189 — applyToWorld() iterates zoneManager.getAllZones())
  • ZoneManager.java (lines 138-181 — async loadAll() via CompletableFuture)

Suggested fix: Chain spawn suppression application to the zone loading CompletableFuture completion, or re-apply spawn suppression after zones finish loading.

Steps to Reproduce

  1. Create a faction zone with mob-spawn = false
  2. Verify mobs are blocked from spawning in the zone
  3. Restart the server
  4. Observe mobs spawning in the zone that should block them

Expected Behavior

Zone-level mob spawn restrictions should be enforced immediately after server restart, regardless of async zone loading order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions