Skip to content

Commit c1582a8

Browse files
committed
Prevent concurrent modification exception
1 parent c6ed2a8 commit c1582a8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/world/bentobox/bentobox/listeners/flags/protection/PhysicalInteractionListener.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package world.bentobox.bentobox.listeners.flags.protection;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
35
import java.util.Map;
46

57
import org.bukkit.Material;
@@ -91,11 +93,15 @@ private boolean checkBlocks(Event e, Player player, Block block) {
9193
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
9294
public void onProjectileExplode(EntityExplodeEvent e) {
9395
if (e.getEntity() instanceof Projectile p && p.getShooter() instanceof Player player) {
96+
List<Block> blocksToRemove = new ArrayList<>();
97+
9498
for (Block b : e.blockList()) {
9599
if (!this.checkBlocks(e, player, b)) {
96-
e.blockList().clear();
100+
blocksToRemove.add(b);
97101
}
98102
}
103+
104+
e.blockList().removeAll(blocksToRemove);
99105
}
100106
}
101107

0 commit comments

Comments
 (0)