mirror of
https://github.com/craftaro/EpicSpawners.git
synced 2025-01-07 03:07:06 +08:00
Fix ConcurrentModification error
This commit is contained in:
parent
2cdbef2ee3
commit
cbfe903745
@ -6,6 +6,9 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WorldListeners implements Listener {
|
||||
private final EpicSpawners plugin;
|
||||
|
||||
@ -16,10 +19,12 @@ public class WorldListeners implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent e) {
|
||||
// Unload previous spawners belonging to this world.
|
||||
List<PlacedSpawner> remove = new ArrayList<>();
|
||||
for (PlacedSpawner ps : this.plugin.getSpawnerManager().getSpawners()) {
|
||||
if (e.getWorld().getName().equals(ps.getWorld().getName())) {
|
||||
this.plugin.getSpawnerManager().removeSpawnerFromWorld(ps);
|
||||
if (ps.getWorld() == null || e.getWorld().getName().equals(ps.getWorld().getName())) {
|
||||
remove.add(ps);
|
||||
}
|
||||
}
|
||||
this.plugin.getSpawnerManager().removeSpawnersFromWorld(remove);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user