mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 02:35:21 +01:00
Prevent concurrent modification exception
This commit is contained in:
parent
c6ed2a8ccd
commit
c1582a81cd
@ -1,5 +1,7 @@
|
||||
package world.bentobox.bentobox.listeners.flags.protection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -91,11 +93,15 @@ public class PhysicalInteractionListener extends FlagListener
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onProjectileExplode(EntityExplodeEvent e) {
|
||||
if (e.getEntity() instanceof Projectile p && p.getShooter() instanceof Player player) {
|
||||
List<Block> blocksToRemove = new ArrayList<>();
|
||||
|
||||
for (Block b : e.blockList()) {
|
||||
if (!this.checkBlocks(e, player, b)) {
|
||||
e.blockList().clear();
|
||||
blocksToRemove.add(b);
|
||||
}
|
||||
}
|
||||
|
||||
e.blockList().removeAll(blocksToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user