99import de .timecoding .cc .util .type .Cube ;
1010import org .bukkit .Bukkit ;
1111import org .bukkit .Location ;
12+ import org .bukkit .block .Block ;
1213import org .bukkit .entity .Player ;
1314import org .bukkit .event .EventHandler ;
1415import org .bukkit .event .Listener ;
1516import org .bukkit .event .block .BlockBreakEvent ;
1617import org .bukkit .event .block .BlockExplodeEvent ;
1718import org .bukkit .event .block .BlockPlaceEvent ;
19+ import org .bukkit .event .entity .EntityExplodeEvent ;
1820
1921import java .util .ConcurrentModificationException ;
22+ import java .util .concurrent .atomic .AtomicBoolean ;
2023import java .util .concurrent .atomic .AtomicReference ;
2124
2225public class CubicListener implements Listener {
@@ -55,11 +58,16 @@ public void onBlockBreak(BlockBreakEvent event) {
5558 }
5659
5760 @ EventHandler
58- public void onBlockExplode (BlockExplodeEvent event ) {
59- proof (null , event .getBlock ().getLocation (), true );
61+ public void onEntityExplode (EntityExplodeEvent event ) {
62+ boolean stop = false ;
63+ for (Block block : event .blockList ()){
64+ if (!stop && proof (null , block .getLocation (), true )){
65+ stop = true ;
66+ }
67+ }
6068 }
6169
62- public CubicListener proof (Player player , Location origin , boolean breakBlock ) {
70+ public boolean proof (Player player , Location origin , boolean breakBlock ) {
6371 DataHandler dataHandler = plugin .getDataHandler ();
6472 AtomicReference <Cube > atomicCube = new AtomicReference <>();
6573 plugin .getCubes ().forEach (searchedCube -> {
@@ -78,21 +86,25 @@ public CubicListener proof(Player player, Location origin, boolean breakBlock) {
7886 Bukkit .getPluginManager ().callEvent (event );
7987 if (!event .isCancelled ()) {
8088 countdownModule .start ();
89+ return true ;
8190 }
8291 } else if (atomicCube .get () != null && breakBlock ) {
92+ AtomicBoolean r = new AtomicBoolean (false );
8393 try {
8494 plugin .getCountdownList ().forEach (countdownModule -> {
8595 if (countdownModule .getCubicSettings ().getCube () != null && countdownModule .getCubicSettings ().getCube ().isSimilar (atomicCube .get ())) {
8696 CubeUnFilledEvent event = new CubeUnFilledEvent (player , countdownModule );
8797 Bukkit .getPluginManager ().callEvent (event );
8898 if (!event .isCancelled ()) {
8999 countdownModule .cancel ();
100+ r .set (true );
90101 }
91102 }
92103 });
93104 //TODO
94105 }catch (ConcurrentModificationException exception ){}
106+ return r .get ();
95107 }
96- return this ;
108+ return false ;
97109 }
98110}
0 commit comments