Bedrock Mining Help

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:​
      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) (p.getItemInHand().getDurability() + 40));
                    ItemStack bedrock = new ItemStack(
                      Material.BEDROCK, 1);
                    if (Main.this.dropBedrock) {
              }, this.time * 20);
    [LEFT]If you can see what I'm doing wrong, that would be great! Thanks, xTeCnOxShAdOwZz[/LEFT]
    [B][LEFT]When I'd like it by: [/LEFT][/B][LEFT]Soon[/LEFT][/CENTER]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
  2. Offline


    Wrong section and only bump every 24 hours
  3. Offline

    Jade Retired Staff

    Moved to correct section and please only bump once every 24 hours.
Thread Status:
Not open for further replies.

Share This Page