mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-09-27 14:12:59 +02:00
Fix concurrent modification exception
This commit is contained in:
parent
d9612b0cfe
commit
d88c61fc94
@ -89,12 +89,15 @@ public class StackingTask extends BukkitRunnable {
|
|||||||
//Filter non-stackable entities to improve performance on main thread
|
//Filter non-stackable entities to improve performance on main thread
|
||||||
entities.removeIf(this::isEntityNotStackable);
|
entities.removeIf(this::isEntityNotStackable);
|
||||||
|
|
||||||
for (LivingEntity entity : entities) {
|
List<LivingEntity> remove = new ArrayList<>();
|
||||||
|
for (LivingEntity entity : entities) { //Q: What can cause current modification exception here?
|
||||||
// Check our WorldGuard flag.
|
// Check our WorldGuard flag.
|
||||||
Boolean flag = WorldGuardHook.isEnabled() ? WorldGuardHook.getBooleanFlag(entity.getLocation(), "mob-stacking") : null; //Does this work async?
|
Boolean flag = WorldGuardHook.isEnabled() ? WorldGuardHook.getBooleanFlag(entity.getLocation(), "mob-stacking") : null; //Does this work async?
|
||||||
if (flag != null && !flag)
|
if (flag != null && !flag) {
|
||||||
entities.removeIf(entity1 -> entity1.getUniqueId().equals(entity.getUniqueId()));
|
remove.add(entity);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
entities.removeAll(remove);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
// Loop through the entities.
|
// Loop through the entities.
|
||||||
|
Loading…
Reference in New Issue
Block a user