Rig_click_air don't work. Where is my mistake?

Discussion in 'Plugin Development' started by bars96, Jan 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    bars96

    Code:
     @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlayerInteract(PlayerInteractEvent e) {
    int id = e.getPlayer().getItemInHand().getTypeId();
    if ((e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) && isBlocked(id) == true) {
    Player p = e.getPlayer();
    Block b = p.getTargetBlock((HashSet<Byte>) null, 300);
    WorldGuardPlugin wg = (WorldGuardPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
    if (!wg.canBuild(p, b)) {
    if (p.hasPermission("laserlog.bypass")) return;
    p.sendMessage("§cYou don't have permission for that area");
    e.setCancelled(true);
    if (plugin.console) plugin.logger.info("[LaserLog] Player: " + p.getName() + " (X: " + p.getLocation().getX() + ", Y: " + p.getLocation().getY() + ", Z: " + p.getLocation().getZ() + "); Target (X: " + b.getX() + ", Y: " + b.getY() + ", Z: " + b.getZ() + ")");
    }
    }
    }
     
    private boolean isBlocked(int id) {
    if (plugin.blocked.contains(id)) return true;
    return false;
    }
    When I right click block with blocked item, event cancelled and it works fine. But when I right click air, event don't cancelled.
     
  2. Offline

    Mathias Eklund

    add debug messages and see what happens.
     
Thread Status:
Not open for further replies.

Share This Page