From e9ebf56b00ad4257fdb73bf8f2fb455fd4f7c005 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:20:13 +0200 Subject: [PATCH] change: annule explosion if source in city protected --- .../city/listeners/protections/ExplodeProtection.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java b/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java index 4e8b8125f..28753f9b8 100644 --- a/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java +++ b/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java @@ -47,7 +47,7 @@ public void onEntityExplode(EntityExplodeEvent event) { if (tnt.getSource() instanceof Player player) { handlePlayerTntExplosion(event, player); } else { - handleAnonymousTntExplosion(event); + handleNaturalExplosion(event); } return; } @@ -137,11 +137,12 @@ private void notifyCityMembers(City city, City attackerCity, Player attacker) { } } - private void handleAnonymousTntExplosion(EntityExplodeEvent event) { - event.blockList().removeIf(block -> !ProtectionsManager.canExplodeNaturally(block.getLocation())); - } - private void handleNaturalExplosion(EntityExplodeEvent event) { + if (!ProtectionsManager.canExplodeNaturally(event.getLocation())) { + event.setCancelled(true); + return; + } + event.blockList().removeIf(block -> !ProtectionsManager.canExplodeNaturally(block.getLocation())); } }