@@ -131,15 +131,15 @@ public void onBlockIgnite(BlockIgniteEvent event) {
131131
132132 @ EventHandler
133133 public void onPiston (BlockPistonExtendEvent event ) {
134- boolean result = this .handlePiston (event .getBlocks (), event .getBlock (), event .getDirection ());
135- if (result )
134+ boolean cancelled = this .handlePiston (event .getBlocks (), event .getBlock (), event .getDirection ());
135+ if (cancelled )
136136 event .setCancelled (true );
137137 }
138138
139139 @ EventHandler
140140 public void onPiston (BlockPistonRetractEvent event ) {
141- boolean result = this .handlePiston (event .getBlocks (), event .getBlock (), event .getDirection ());
142- if (result )
141+ boolean cancelled = this .handlePiston (event .getBlocks (), event .getBlock (), event .getDirection ());
142+ if (cancelled )
143143 event .setCancelled (true );
144144 }
145145
@@ -156,8 +156,9 @@ private void handleRegionExplode(@NotNull List<Block> blockList, @Nullable Block
156156 }
157157
158158 private boolean handlePiston (@ NotNull List <Block > blockList , @ NotNull Block pistonBlock , @ NotNull BlockFace direction ) {
159- Location retractLocation = pistonBlock .getRelative (direction , blockList .size ()).getLocation ();
160- Region region = this .manager .getRegionByLocation (retractLocation );
159+ int distance = blockList .size ();
160+ Location location = pistonBlock .getRelative (direction , distance ).getLocation ();
161+ Region region = this .manager .getRegionByLocation (location );
161162 if (region != null ) return true ;
162163
163164 for (Block block : blockList ) {
0 commit comments