Skip to content

Commit

Permalink
Fixed mob counts reset when chunks unload while in recalculate cooldo…
Browse files Browse the repository at this point in the history
…wn (#1420)
  • Loading branch information
OmerBenGera committed Oct 20, 2022
1 parent 2b67ec1 commit 0d8d70f
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -76,8 +76,10 @@ public void loadChunk(Chunk chunk) {

if (BuiltinModules.UPGRADES.isUpgradeTypeEnabled(UpgradeTypeEntityLimits.class)) {
BukkitExecutor.sync(() -> {
if (chunk.isLoaded())
if (chunk.isLoaded()) {
Arrays.stream(chunk.getEntities()).forEach(entityTrackingListener.get()::onEntitySpawn);
island.getEntitiesTracker().recalculateEntityCounts();
}
}, 20L);
}
}
Expand Down Expand Up @@ -108,8 +110,7 @@ public void unloadChunk(Chunk chunk) {
if (!island.isSpawn() && !plugin.getNMSChunks().isChunkEmpty(chunk))
island.markChunkDirty(chunk.getWorld(), chunk.getX(), chunk.getZ(), true);

Arrays.stream(chunk.getEntities()).forEach(entityTrackingListener.get()::onEntitySpawn);

Arrays.stream(chunk.getEntities()).forEach(entityTrackingListener.get()::onEntityDespawn);
}

}

0 comments on commit 0d8d70f

Please sign in to comment.