@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { return; } if (event.getClickedBlock() == null || event.getClickedBlock().getType() == Material.AIR) { return; } if (!context.isValidWorld(event.getPlayer().getWorld().getName())) return; SafeCityPlayer scPlayer = context.getPlayer(event.getPlayer()); if (scPlayer.getCoolDownState()) { return; } if (scPlayer.getZoneManager().isResizing()) { return; } boolean hasTool = false; if (scPlayer.getBukkitPlayer().getItemInHand().getType() == SafeCityTool.ZoneTool.material()) { hasTool = true; } if (scPlayer.getBukkitPlayer().getItemInHand().getType() == SafeCityTool.ZoneTool3d.material()) { hasTool = true; } if (!hasTool) { return; } World blockWorld = event.getClickedBlock().getWorld(); Location blockLocation = event.getClickedBlock().getLocation(); ThinLocation blockThinLocation = context.toThinLocation(blockLocation); // does a zone already exist here? SafeCityZone zone = context.getZone(blockThinLocation, blockWorld); SafeCitySubZone subZone = context.getSubZone(blockThinLocation, blockWorld); // if clicked a corner, ignore (resizing) if (zone != null && zone.isCornerLocation(blockThinLocation, blockWorld, false)) { return; } if (subZone != null && subZone.isCornerLocation(blockThinLocation, blockWorld, true)) { return; } // check if player has permission if (!this.checkPermission(event, scPlayer, zone, subZone)) { return; } initCreation(event, scPlayer, zone); }