@@ -165,52 +165,51 @@ private void movePlayerBack(GenericPlayer player, Location movingFrom, Location
165
165
166
166
@ EventHandler
167
167
public void onBlockBreak (BlockBreakEvent event ) {
168
+ if (event .getPlayer ().getItemOnCursor ().getType () == Material .STICK ) return ;
168
169
GenericPlayer player = plugin .getPlayer (event .getPlayer ());
169
170
if (player == null ) {
170
171
return ;
171
172
}
172
173
ItemStack item = player .getItemInHand ();
173
- if (item .getType () == Material .STICK ) {
174
- event .setCancelled (true );
174
+ event .setCancelled (true );
175
175
176
- Block block = event .getBlock ();
177
- Point currentPos = new Point (block .getX (), block .getZ ());
178
- ZoneWorld world = plugin .getWorld (block .getWorld ());
179
- Zone zone = world .findZone (currentPos );
180
- Lot lot = world .findLot (currentPos );
181
- // within a zone, lots can be created by zone owners or people with
182
- // the zones permission.
183
- String type = null ;
184
- if (zone != null ) {
185
- Zone .Permission perm = zone .getUser (player );
186
- if (perm != Zone .Permission .Owner && !player .getRank ().canModifyZones ()) {
176
+ Block block = event .getBlock ();
177
+ Point currentPos = new Point (block .getX (), block .getZ ());
178
+ ZoneWorld world = plugin .getWorld (block .getWorld ());
179
+ Zone zone = world .findZone (currentPos );
180
+ Lot lot = world .findLot (currentPos );
181
+ // within a zone, lots can be created by zone owners or people with
182
+ // the zones permission.
183
+ String type = null ;
184
+ if (zone != null ) {
185
+ Zone .Permission perm = zone .getUser (player );
186
+ if (perm != Zone .Permission .Owner && !player .getRank ().canModifyZones ()) {
187
187
188
- return ;
189
- }
190
- if (lot != null ) {
191
- player .sendMessage ("This lot is called " + lot .getName () + "." );
192
- return ;
193
- }
194
- type = "lot" ;
188
+ return ;
195
189
}
196
- // outside of a zone
197
- else {
198
- // outside of any existing zone, this can only be used by people
199
- // with zones permission.
200
- if (!player .getRank ().canModifyZones ()) {
201
- return ;
202
- }
203
- type = "zone" ;
190
+ if (lot != null ) {
191
+ player .sendMessage ("This lot is called " + lot .getName () + "." );
192
+ return ;
204
193
}
205
- if (player .getZoneBlock1 ().getLocation ().distance (block .getLocation ()) == 0 )
194
+ type = "lot" ;
195
+ }
196
+ // outside of a zone
197
+ else {
198
+ // outside of any existing zone, this can only be used by people
199
+ // with zones permission.
200
+ if (!player .getRank ().canModifyZones ()) {
206
201
return ;
207
- player .setZoneBlock1 (block );
208
- event .getPlayer ().sendMessage ("First block set of new " + type + "." );
209
- if (zone != null ) {
210
- player .setTargetZoneId (zone .getId ());
211
- } else {
212
- player .setTargetZoneId (0 );
213
202
}
203
+ type = "zone" ;
204
+ }
205
+ if (player .getZoneBlock1 () != null && player .getZoneBlock1 ().getLocation ().distance (block .getLocation ()) == 0 )
206
+ return ;
207
+ player .setZoneBlock1 (block );
208
+ event .getPlayer ().sendMessage ("First block set of new " + type + "." );
209
+ if (zone != null ) {
210
+ player .setTargetZoneId (zone .getId ());
211
+ } else {
212
+ player .setTargetZoneId (0 );
214
213
}
215
214
}
216
215
0 commit comments