Can't cancel event

Discussion in 'Plugin Development' started by xTeCnOxShAdOwZz, Apr 9, 2014.

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


    Plugin category:​
    Tool Modification​

    Suggested name:​

    What I want:​
    Basically, I have coded 99% of my plugin which allows a player to receive a special plugin which has the ability to mine bedrock. It does work, but I have a problem where the event that causes the bedrock that is being mined to be destroyed even if the player stops mining it.​
    I have a timer where it can take, for example, 5 seconds for the bedrock to be mined, but the event is triggered when a player left-clicks a block of bedrock. This means that even if they tap it with the pickaxe, then wait 5 seconds, it will dissappear. I want the player to have to keep their mouse held on the block, like normal block destruction.​
    I don't know how to code it so that upon cancelling mining the block, it will also cancel the event.​
    Here is some of the code (I have only been coding for 2 days, so don't take the mick please):​
    public void onPlayerInteract(PlayerInteractEvent event)
    final Block block = event.getClickedBlock();
    final Player p = event.getPlayer();
    if ((event.getAction() == Action.RIGHT_CLICK_AIR) ||
    (event.getAction() == Action.RIGHT_CLICK_BLOCK) ||
    (event.getAction() == Action.PHYSICAL)) {
    if (this.bedrockMiners.contains(p.getName()))
    ItemStack item = p.getItemInHand();
    if ((item.getType() == this.reqItem.getType()) &&
    (event.getItem().getItemMeta().getDisplayName().equals(ChatColor.DARK_AQUA + getConfig().getString("Name"))) &&
    (event.getClickedBlock().getType().equals(Material.BEDROCK)) &&
    (block.getLocation().getY() >= this.minBreakY)) {
    new Runnable()
    public void run()
    if (p.getLocation().distance(block.getLocation()) < 6.0D)

    p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, 10, 1);
    (short[​IMG]) (p.getItemInHand().getDurability() + 40));
    ItemStack bedrock = new ItemStack(
    Material.BEDROCK, 1);
    if (Main.this.dropBedrock) {
    }, this.time * 20);
  2. Offline


    Hey there, could you consider pasting your code in a code tag? (between
    or by pressing the code button in the editor and pasting your code in)

    It would make it easier to read and then people are more likely to try and help. :)
Thread Status:
Not open for further replies.

Share This Page