Skip to content

Commit

Permalink
fix: spawn all npcs in already loaded chunks on start (#1255)
Browse files Browse the repository at this point in the history
### Motivation
When a npc is located in the spawn chunks of the world the npc won't get
spawned. This is caused by the fact that the chunk load event is called
before our plugin is started.

### Modification
Spawned all npcs on start that are located in already loaded chunks

### Result
No non existing npcs
  • Loading branch information
0utplay committed Jun 15, 2023
1 parent daa3096 commit a10a86f
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ public BukkitPlatformNPCManagement(
}, 20, 5);
}

@Override
public void initialize() {
super.initialize();

// spawn all npcs that are in chunks that were loaded before the plugin was enabled
for (var entity : this.trackedEntities.values()) {
if (entity.canSpawn()) {
entity.spawn();
}
}
}

@Override
protected @NonNull PlatformSelectorEntity<Location, Player, ItemStack, Inventory, Scoreboard> createSelectorEntity(
@NonNull NPC base
Expand Down

0 comments on commit a10a86f

Please sign in to comment.