Esempio n. 1
0
  @Override
  public boolean onDamageOther(EntityDamageByEntityEvent e, Player p, int level) {
    if (e.getEntity() instanceof LivingEntity) {
      LivingEntity le = (LivingEntity) e.getEntity();

      try {
        fireworks.playFirework(
            le.getWorld(),
            le.getLocation(),
            FireworkEffect.builder().with(Type.BURST).withColor(Color.WHITE).build());
      } catch (Exception ex) {
        Logger.getLogger(Burst.class.getName()).log(Level.SEVERE, null, ex);
      }

      Vector unitVector =
          le.getLocation().toVector().subtract(e.getDamager().getLocation().toVector()).normalize();

      unitVector.setY(0.55 / level);

      le.setVelocity(unitVector.multiply(level * 2));

      e.setCancelled(true);

      return true;
    }
    return false;
  }
  @Override
  public void run() {
    timesRan++;

    Location lFx = l;
    lFx.add(0, 2 * timesRan, 0);

    if (timesRan == 0) {

    } else if (timesRan == 5) {
      try {
        fireworks.playFirework(
            lFx.getWorld(),
            lFx,
            FireworkEffect.builder()
                .with(FireworkEffect.Type.CREEPER)
                .withColor(Color.GREEN)
                .build());
      } catch (Exception ex) {
        // Gracefully downgrade
      }

      plugin.bossManager.hatchBossAtLocation(l);

      this.cancel();

      return;
    }

    try {
      fireworks.playFirework(
          lFx.getWorld(),
          lFx,
          FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.PURPLE).build());
    } catch (Exception ex) {
      // Gracefully downgrade
    }
  }