Drill......

Discussion in 'Plugin Development' started by Pr0_fAssEr, Aug 7, 2015.

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

    Pr0_fAssEr

    Hello, so i saw a video about the drill plugin ( )
    and i told myself that i can make myself this plugin.
    but i dont know why its doesnt work good.

    The code:
    Code:
        public void start(Player p,Location loc) {
           
                new BukkitRunnable() {
                   
                    int i = 0;
                    @Override
                    public void run() {
                        i++;
                        if(loc.subtract(0, i, 0).getBlock().getType() == Material.BEDROCK) {
                            for(int test = 0; test < i; test++) {
                                loc.add(0, i, 0).getBlock().setType(Material.DIRT);
                                p.sendMessage("Drill has been over!");
                                cancel();
                            }
                            return;
                        }
                        if(loc.subtract(0, i, 0).getBlock().getType() == Material.AIR) {
                            loc.subtract(0, i, 0).getBlock().setType(Material.COBBLE_WALL);
                            return;
                        }
                        String nameOfBlock = loc.subtract(0, i, 0).getBlock().getType().toString().toLowerCase().trim();
                        Material id = loc.subtract(0, i, 0).getBlock().getType();
                        loc.subtract(0, i, 0).getBlock().setType(Material.COBBLE_WALL);
                        p.sendMessage("Just broke " + nameOfBlock);
                        p.getInventory().addItem(new ItemStack(id));
                        p.sendMessage("" + i);
                    }
                }.runTaskTimer(this, 20, 20);
           
        }
       
        @EventHandler
        public void drill(PlayerInteractEvent e) {
            if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                if(e.getClickedBlock().getType() == Material.FENCE && e.getClickedBlock().getRelative(BlockFace.EAST).getType() == Material.IRON_BLOCK && e.getClickedBlock().getRelative(BlockFace.WEST).getType() == Material.IRON_BLOCK && e.getClickedBlock().getRelative(BlockFace.UP).getType() == Material.REDSTONE_TORCH_ON) {
                    Location loc = e.getClickedBlock().getLocation();
                    e.getPlayer().sendMessage("The Drill is on, please wait 30 seconds.");
                    start(e.getPlayer(), loc);
                }
            }
        }
    its breaking i dont know why 5 blocks or 6 or 7 like a random number under the drill....

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
Thread Status:
Not open for further replies.

Share This Page