Skip to content

Commit

Permalink
Fix ConcurrentModificationException in despawning loop
Browse files Browse the repository at this point in the history
  • Loading branch information
RiledUpCrow committed Mar 14, 2016
1 parent e6e092a commit 4dc3946
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/pl/betoncraft/hordes/Despawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void run() {
WorldSettings settings = plugin.getWorlds().get(world.getName());
if (settings == null) continue;
// copy the array so it does not get modified while iterating
for (Entity entity : new ArrayList<>(world.getEntities())) {
ArrayList<Entity> entities = new ArrayList<>(world.getEntities());
for (Entity entity : entities) {
if (!settings.shouldExist(entity)){
entity.remove();
}
Expand Down

0 comments on commit 4dc3946

Please sign in to comment.