Ejemplo n.º 1
0
  // @EventHandler(priority = EventPriority.NORMAL)
  public void explodingArrow(ProjectileHitEvent event) {
    Entity projectile = event.getEntity();
    World w = projectile.getWorld();
    Location hit = projectile.getLocation();

    if (w.getName().equals(name)) {

      if (projectile instanceof Arrow) {
        Arrow arrow = (Arrow) projectile;
        Entity shooter = arrow.getShooter();
        Location l = shooter.getLocation();
        Block bl = l.getBlock();
        Block b = bl.getRelative(BlockFace.DOWN, 2);
        Material mat = b.getType();

        if (shooter instanceof Player) {
          Player p = (Player) shooter;
          ItemStack is = p.getItemInHand();
          Material i = is.getType();
          if (i == Material.BOW && mat == Material.SPONGE) {
            p.getInventory().removeItem(new ItemStack(Material.ARROW, 20));
            w.createExplosion(hit, 8);
            int strikes = 0;
            while (strikes < 20) {
              strikes++;
              w.strikeLightning(hit);
            }
          }
          Bukkit.getWorld(name).playEffect(arrow.getLocation(), Effect.STEP_SOUND, 10);
        }
      }
    }
  }