How to cancel an onBlockRightClick event?

Discussion in 'Plugin Development' started by Borch, Jan 19, 2011.

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

    Borch

    Hey, I want to prevent a player from pushing a button, tuning a note block etc..
    I assumed I have to stop the BlockRightClickEvent in onBlockRightClick(), but it doesn't have a "setCancelled()" method or anything. So how to do this then?
     
  2. Offline

    Borch

    This also doesn't work :-(

    Code:
        @Override
        public void onBlockInteract(BlockInteractEvent event)
        {
            // Is the interacting entity a player?
            if (!(event.getEntity() instanceof Player)) return;
            Player player = (Player)event.getEntity(); // cast...
            if (SpProtect.isAdmin(player)) return; // admin check
            if (event.getBlock().getTypeId() == 25 && plugin.isProtectedArea(event.getBlock())) { // cancel manipulation of note blocks
                event.setCancelled(true);
            }
        }
    Any hints?
     
Thread Status:
Not open for further replies.

Share This Page