@@ -22,8 +22,7 @@ public class BlockEnvironmentListener implements Listener{
2222 // Prevent explosion break block
2323 @ EventHandler (priority = EventPriority .HIGH )
2424 public void onEntityExplode (EntityExplodeEvent event ){
25- if (Config .isProtectionExempted ("explosion" )) return ;
26- if (event .getLocation () != null && Config .isDisabledWorld (event .getLocation ().getWorld ().getName ())) return ;
25+ if (Config .isProtectionExempted ("explosion" ) || Config .isDisabledWorld (event .getLocation ())) return ;
2726 Iterator <Block > it = event .blockList ().iterator ();
2827 while (it .hasNext ()) {
2928 Block block = it .next ();
@@ -34,8 +33,7 @@ public void onEntityExplode(EntityExplodeEvent event){
3433 // Prevent bed break block
3534 @ EventHandler (priority = EventPriority .HIGH )
3635 public void onBlockExplode (BlockExplodeEvent event ){
37- if (Config .isProtectionExempted ("explosion" )) return ;
38- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
36+ if (Config .isProtectionExempted ("explosion" ) || Config .isDisabledWorld (event .getBlock ())) return ;
3937 Iterator <Block > it = event .blockList ().iterator ();
4038 while (it .hasNext ()) {
4139 Block block = it .next ();
@@ -46,8 +44,7 @@ public void onBlockExplode(BlockExplodeEvent event){
4644 // Prevent tree break block
4745 @ EventHandler (priority = EventPriority .HIGH )
4846 public void onStructureGrow (StructureGrowEvent event ){
49- if (Config .isProtectionExempted ("growth" )) return ;
50- if (event .getWorld () != null && Config .isDisabledWorld (event .getWorld ().getName ())) return ;
47+ if (Config .isProtectionExempted ("growth" ) || Config .isDisabledWorld (event .getWorld ().getName ())) return ;
5148 for (BlockState blockstate : event .getBlocks ()){
5249 if (LocketteProAPI .isProtected (blockstate .getBlock ())){
5350 event .setCancelled (true );
@@ -59,8 +56,7 @@ public void onStructureGrow(StructureGrowEvent event){
5956 // Prevent piston extend break lock
6057 @ EventHandler (priority = EventPriority .HIGH )
6158 public void onPistonExtend (BlockPistonExtendEvent event ){
62- if (Config .isProtectionExempted ("piston" )) return ;
63- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
59+ if (Config .isProtectionExempted ("piston" ) || Config .isDisabledWorld (event .getBlock ())) return ;
6460 for (Block block : event .getBlocks ()){
6561 if (LocketteProAPI .isProtected (block )){
6662 event .setCancelled (true );
@@ -72,8 +68,7 @@ public void onPistonExtend(BlockPistonExtendEvent event){
7268 // Prevent piston retract break lock
7369 @ EventHandler (priority = EventPriority .HIGH )
7470 public void onPistonRetract (BlockPistonRetractEvent event ){
75- if (Config .isProtectionExempted ("piston" )) return ;
76- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
71+ if (Config .isProtectionExempted ("piston" ) || Config .isDisabledWorld (event .getBlock ())) return ;
7772 for (Block block : event .getBlocks ()){
7873 if (LocketteProAPI .isProtected (block )){
7974 event .setCancelled (true );
@@ -85,8 +80,7 @@ public void onPistonRetract(BlockPistonRetractEvent event){
8580 // Prevent redstone current open doors
8681 @ EventHandler (priority = EventPriority .HIGH )
8782 public void onBlockRedstoneChange (BlockRedstoneEvent event ){
88- if (Config .isProtectionExempted ("redstone" )) return ;
89- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
83+ if (Config .isProtectionExempted ("redstone" ) || Config .isDisabledWorld (event .getBlock ())) return ;
9084 if (LocketteProAPI .isProtected (event .getBlock ())){
9185 event .setNewCurrent (event .getOldCurrent ());
9286 }
@@ -95,8 +89,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event){
9589 // Prevent villager open door
9690 @ EventHandler (priority = EventPriority .HIGH )
9791 public void onVillagerOpenDoor (EntityInteractEvent event ){
98- if (Config .isProtectionExempted ("villager" )) return ;
99- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
92+ if (Config .isProtectionExempted ("villager" ) || Config .isDisabledWorld (event .getBlock ())) return ;
10093 // Explicitly to villager vs all doors
10194 if (event .getEntity () instanceof Villager &&
10295 (LocketteProAPI .isSingleDoorBlock (event .getBlock ()) || LocketteProAPI .isDoubleDoorBlock (event .getBlock ())) &&
@@ -108,8 +101,7 @@ public void onVillagerOpenDoor(EntityInteractEvent event){
108101 // Prevent Enderman take block
109102 @ EventHandler (priority = EventPriority .HIGH )
110103 public void onEndermanGreif (EntityInteractEvent event ){
111- if (Config .isProtectionExempted ("enderman" )) return ;
112- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
104+ if (Config .isProtectionExempted ("enderman" ) || Config .isDisabledWorld (event .getBlock ())) return ;
113105 if (event .getEntity () instanceof Enderman && LocketteProAPI .isProtected (event .getBlock ())){
114106 event .setCancelled (true );
115107 }
0 commit comments