3737import org .bukkit .command .CommandSender ;
3838import org .bukkit .enchantments .Enchantment ;
3939import org .bukkit .entity .Player ;
40+ import org .bukkit .entity .WindCharge ;
4041import org .bukkit .event .Event ;
4142import org .bukkit .event .EventHandler ;
4243import org .bukkit .event .EventPriority ;
5051import org .bukkit .event .player .PlayerJoinEvent ;
5152import org .bukkit .event .player .PlayerTeleportEvent ;
5253import org .bukkit .event .player .PlayerTeleportEvent .TeleportCause ;
53- import org .bukkit .inventory .Inventory ;
5454import org .bukkit .inventory .ItemStack ;
5555
5656import java .util .List ;
@@ -372,7 +372,7 @@ public void onSpongeAbsorb(SpongeAbsorbEvent event) {
372372 event .setCancelled (true );
373373 }
374374 }
375-
375+
376376 @ EventHandler (priority = EventPriority .HIGH , ignoreCancelled = true )
377377 public void onBlockFade (BlockFadeEvent e ) {
378378 if (ProtectionStones .isProtectBlock (e .getBlock ())) {
@@ -437,26 +437,27 @@ private void pistonUtil(List<Block> pushedBlocks, BlockPistonEvent e) {
437437
438438 @ EventHandler (priority = EventPriority .HIGH , ignoreCancelled = true )
439439 public void onBlockExplode (BlockExplodeEvent e ) {
440- explodeUtil (e .blockList (), e .getBlock ().getLocation ().getWorld ());
440+ explodeUtil (e .blockList (), e .getBlock ().getLocation ().getWorld (), false );
441441 }
442442
443443 @ EventHandler (priority = EventPriority .HIGH , ignoreCancelled = true )
444444 public void onEntityExplode (EntityExplodeEvent e ) {
445- explodeUtil (e .blockList (), e .getLocation ().getWorld ());
445+ boolean isWindCharge = e .getEntity () instanceof WindCharge ;
446+ explodeUtil (e .blockList (), e .getLocation ().getWorld (), isWindCharge );
446447 }
447448
448449 @ EventHandler (priority = EventPriority .HIGH , ignoreCancelled = true )
449450 public void onEntityChangeBlock (EntityChangeBlockEvent e ) {
450451 if (!ProtectionStones .isProtectBlock (e .getBlock ())) return ;
451452
452453 // events like ender dragon block break, wither running into block break, etc.
453- if (!blockExplodeUtil (e .getBlock ().getWorld (), e .getBlock ())) {
454+ if (!blockExplodeUtil (e .getBlock ().getWorld (), e .getBlock (), false )) {
454455 // if block shouldn't be exploded, cancel the event
455456 e .setCancelled (true );
456457 }
457458 }
458459
459- private void explodeUtil (List <Block > blockList , World w ) {
460+ private void explodeUtil (List <Block > blockList , World w , boolean isWindCharge ) {
460461 // loop through exploded blocks
461462 for (int i = 0 ; i < blockList .size (); i ++) {
462463 Block b = blockList .get (i );
@@ -467,12 +468,12 @@ private void explodeUtil(List<Block> blockList, World w) {
467468 i --;
468469 }
469470
470- blockExplodeUtil (w , b );
471+ blockExplodeUtil (w , b , isWindCharge );
471472 }
472473 }
473474
474475 // returns whether the block is exploded
475- private boolean blockExplodeUtil (World w , Block b ) {
476+ private boolean blockExplodeUtil (World w , Block b , boolean isWindCharge ) {
476477 if (ProtectionStones .isProtectBlock (b )) {
477478 String id = WGUtils .createPSID (b .getLocation ());
478479 PSProtectBlock blockOptions = ProtectionStones .getBlockOptions (b );
@@ -482,6 +483,10 @@ private boolean blockExplodeUtil(World w, Block b) {
482483 return false ;
483484 }
484485
486+ if (isWindCharge && blockOptions .preventWindChargeExplode ) {
487+ return false ;
488+ }
489+
485490 // manually set to air if exploded so there is no natural item drop
486491 b .setType (Material .AIR );
487492
0 commit comments