Example #1
0
 private void scheduleMobSpawn(int t) {
   Random r = new Random();
   int d = 0;
   if (t > 0) d = (int) (r.nextInt(t) - t / 2.);
   long time = 20L * (myConfig.getDefaultSpawnTime() + (t <= 0 ? 0 : t) + d);
   this.scheduled += 1;
   Manager.scheduleTask(
       new Runnable() {
         public void run() {
           if (spawnMob()) {
             scheduled -= 1;
           }
         }
       },
       time);
 }
Example #2
0
  @SuppressWarnings("deprecation")
  @Override
  public boolean execute() {
    if (!super.execute()) {
      return false;
    }
    final int r = getRadius();
    Set<Material> set = new HashSet<Material>();
    set.add(Material.AIR);
    final Block target =
        getPlayer().getPlayer().getTargetBlock(set, r * 2).getRelative(BlockFace.UP);
    Vector v =
        target
            .getLocation()
            .toVector()
            .subtract(getPlayer().getPlayer().getEyeLocation().toVector());
    ParticleEffect.EXPLOSION_NORMAL.display(v, 0.2F, getPlayer().getPlayer().getEyeLocation(), 30D);
    Manager.scheduleTask(
        new Runnable() {
          @Override
          public void run() {
            ParticleEffect.EXPLOSION_LARGE.display(
                0.2F, 0.2F, 0.2F, 0.2F, 5, target.getLocation(), 30D);
            target.getWorld().playSound(target.getLocation(), Sound.EXPLODE, 0.6F, 0.9F);
            for (Entity e : target.getWorld().getEntities()) {
              if (((e instanceof LivingEntity))
                  && (e.getEntityId() != getPlayer().getPlayer().getEntityId())
                  && (e.getLocation().distanceSquared(target.getLocation()) <= r * r)) {
                EntityDamageByEntityEvent event =
                    new EntityDamageByEntityEvent(
                        getPlayer().getPlayer(), e, DamageCause.CUSTOM, getDamage());
                Bukkit.getPluginManager().callEvent(event);
              }
            }
          }
        },
        1L * Math.round(v.length()));

    return true;
  }