3434import xzot1k .plugins .ptg .events .PhysicsActionEvent ;
3535
3636import java .util .ArrayList ;
37+ import java .util .HashSet ;
3738import java .util .List ;
3839import java .util .stream .Collectors ;
3940
@@ -120,7 +121,7 @@ public void onForm(EntityChangeBlockEvent e) {
120121 e .setCancelled (true );
121122
122123 if (getPluginInstance ().getManager ().isBlockDataVersion ())
123- e .getEntity ().getWorld ().spawnParticle (Particle .BLOCK_CRACK , e .getEntity ().getLocation (), 10 , e .getBlock ().getBlockData ());
124+ e .getEntity ().getWorld ().spawnParticle (Ref . isNewerThan ( 20 )?(( Particle ) Ref . getStatic ( Particle . class , "BLOCK" )): Particle .BLOCK_CRACK , e .getEntity ().getLocation (), 10 , e .getBlock ().getBlockData ());
124125 else
125126 e .getEntity ().getWorld ().playEffect (e .getEntity ().getLocation (), Effect .STEP_SOUND , e .getBlock ().getType ().getId ());
126127 }
@@ -227,6 +228,15 @@ else getPluginInstance().getServer().getScheduler().runTaskLater(getPluginInstan
227228 }
228229 }
229230
231+ @ EventHandler
232+ public void onFireStart (BlockIgniteEvent e ){
233+ for (BlockState state :new HashSet <>(getPluginInstance ().getManager ().getSavedBlockStates ())){
234+ if (state .getLocation ().equals (e .getBlock ().getLocation ())){
235+ e .setCancelled (true );
236+ }
237+ }
238+ }
239+
230240 @ EventHandler (priority = EventPriority .LOWEST )
231241 public void onBlockExplode (BlockExplodeEvent e ) {
232242 if (e .isCancelled ()) return ;
@@ -240,10 +250,21 @@ public void onBlockExplode(BlockExplodeEvent e) {
240250 e .blockList ().clear ();
241251 return ;
242252 }
253+ Block block ;
254+ Material type ;
255+ if (Ref .isNewerThan (20 )){
256+ Object blockState = Ref .invoke (e , "getExplodedBlockState" );
257+ block =(Block ) Ref .invoke (blockState ,"getBlock" );
258+ type =(Material ) Ref .invoke (blockState ,"getType" );
259+ }else {
260+ block =e .getBlock ();
261+ type =block .getType ();
262+ }
243263
244- e .setYield (handleExplosives (e .blockList (), e .getYield (), null , e . getBlock () ));
264+ e .setYield (handleExplosives (e .blockList (), e .getYield (), null , block , type ));
245265 }
246266
267+
247268 @ EventHandler (priority = EventPriority .LOWEST )
248269 public void onExplode (EntityExplodeEvent e ) {
249270 if (e .isCancelled ()) return ;
@@ -258,14 +279,18 @@ public void onExplode(EntityExplodeEvent e) {
258279 return ;
259280 }
260281
261- e .setYield (handleExplosives (e .blockList (), e .getYield (), e .getEntity (), null ));
282+ if (getPluginInstance ().getWorldGuardHook ().handleExplosion (e )){
283+ return ;
284+ }
285+
286+ e .setYield (handleExplosives (e .blockList (), e .getYield (), e .getEntity (), null ,null ));
262287 }
263288
264289 @ SuppressWarnings ("deprecation" )
265- private float handleExplosives (List <Block > blocklist , float ogYield , Entity entity , Block causeBlock ) {
290+ private float handleExplosives (List <Block > blocklist , float ogYield , Entity entity , Block causeBlock , Material causeBlockType ) {
266291 boolean yield = false ,
267292 isBlockedEntity = (causeBlock == null && entity != null && getPluginInstance ().getManager ().isBlockedExplosiveRegenEntity (entity .getType ())),
268- isBlockedBlock = (entity == null && causeBlock != null && getPluginInstance ().getManager ().isBlockedExplosiveRegenBlock (causeBlock . getType () ));
293+ isBlockedBlock = (entity == null && causeBlock != null && getPluginInstance ().getManager ().isBlockedExplosiveRegenBlock (causeBlockType ));
269294 blocklist .removeIf (block -> getPluginInstance ().getManager ().isAvoidedMaterial (block .getType (), block .getData ()));
270295
271296 final List <Block > blockList = new ArrayList <>(blocklist );
@@ -305,6 +330,7 @@ private float handleExplosives(List<Block> blocklist, float ogYield, Entity enti
305330 continue ;
306331 }
307332
333+
308334 if (physics && ((Math .random () * 100 ) < 15 ) && fallingBlockCount < (blockList .size () * 0.25 )) {
309335 getPluginInstance ().getManager ().createFallingBlock (block , isInventoryHolder ? block .getState () : blockState , true , false );
310336 fallingBlockCount ++;
@@ -333,8 +359,10 @@ private float handleExplosives(List<Block> blocklist, float ogYield, Entity enti
333359
334360 final boolean inverted = getPluginInstance ().getConfig ().getBoolean ("invert-bmr" );
335361 if ((!inverted && getPluginInstance ().getManager ().isBlockedRegenMaterial (block .getType ()))
336- || (inverted && !getPluginInstance ().getManager ().isBlockedRegenMaterial (block .getType ())))
362+ || (inverted && !getPluginInstance ().getManager ().isBlockedRegenMaterial (block .getType ()))) {
337363 continue ;
364+ }
365+
338366
339367 handleSpecialStateRestore (block , isInventoryHolder ? beforeClear : blockState , containerRestore , signRestore );
340368 getPluginInstance ().getManager ().getSavedBlockStates ().add (isInventoryHolder ? block .getState () : blockState );
0 commit comments