Plugin Help Bukkit Grenade Help

Discussion in 'Plugin Help/Development/Requests' started by Kuisser, Oct 25, 2014.

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

    Kuisser

    Hi i made a plugin and i want to throw grenades that blow up 5 seconds after they hit the ground i got it to be thrown but whenever i throw it it blows up immediately and i dont know how to put it on a timer heres my code:
    Code:
        @EventHandler
        public void interact(PlayerInteractEvent e) {
            if (e.getAction() == Action.RIGHT_CLICK_AIR) {
                if (e.getPlayer().getItemInHand() != null) {
                    if (e.getPlayer().getItemInHand().getType() == Material.FIREWORK_CHARGE) {
                        if (e.getPlayer().getItemInHand().getAmount() > 1) {
                            e.getPlayer().getItemInHand().setAmount(e.getPlayer().getItemInHand().getAmount()-1);
                        } else {
                            e.getPlayer().getInventory().setItemInHand(null);
                        }
                        final Item i = e.getPlayer().getWorld().dropItem(e.getPlayer().getEyeLocation(), new ItemStack(Material.FIREWORK_CHARGE));
                        i.setPickupDelay(Integer.MAX_VALUE); //can never be picked up
                        i.getWorld().playEffect(i.getLocation(), Effect.SMOKE, Integer.MAX_VALUE);
                        i.setVelocity(e.getPlayer().getEyeLocation().getDirection());
                        i.getWorld().createExplosion(i.getLocation(), 5.0F);
                        i.remove();
                    }
                }
            }
        }
    }
     
  2. Offline

    Gerov

Thread Status:
Not open for further replies.

Share This Page