Package org.bukkit.entity

Examples of org.bukkit.entity.Firework


   *            Location to explode
   */
  public static void playFirework(Location loc) {
    Random gen = DiabloDrops.getInstance().getSingleRandom();
    try {
      Firework fw = loc.getWorld().spawn(loc, Firework.class);
      Method d0 = getMethod(loc.getWorld().getClass(), "getHandle");
      Method d2 = getMethod(fw.getClass(), "getHandle");
      Object o3 = d0.invoke(loc.getWorld(), (Object[]) null);
      Object o4 = d2.invoke(fw, (Object[]) null);
      Method d1 = getMethod(o3.getClass(), "broadcastEntityEffect");
      FireworkMeta data = fw.getFireworkMeta();
      data.addEffect(FireworkEffect
          .builder()
          .with(FireworkEffect.Type.values()[gen
              .nextInt(FireworkEffect.Type.values().length)])
          .flicker(gen.nextBoolean())
          .trail(gen.nextBoolean())
          .withColor(
              Color.fromRGB(gen.nextInt(255), gen.nextInt(255),
                  gen.nextInt(255)))
          .withFade(
              Color.fromRGB(gen.nextInt(255), gen.nextInt(255),
                  gen.nextInt(255))).build());
      fw.setFireworkMeta(data);
      d1.invoke(o3, new Object[] { o4, (byte) 17 });
      fw.remove();
    } catch (Exception ex) {
      // not a Beta1.4.6R0.2 Server
    }
  }
View Full Code Here


                             (flicker ? aH.debugObj("flicker", flicker) : "") +
                             (trail ? aH.debugObj("trail", trail) : "") +
                             aH.debugObj("primary colors", primary.toString()) +
                             (fade != null ? aH.debugObj("fade colors", fade.toString()) : ""));

        Firework firework = location.getWorld().spawn(location, Firework.class);
        FireworkMeta fireworkMeta = firework.getFireworkMeta();
        fireworkMeta.setPower(power.asInt());

        Builder fireworkBuilder = FireworkEffect.builder();
        fireworkBuilder.with(FireworkEffect.Type.valueOf(type.asString().toUpperCase()));

                          fireworkBuilder.withColor(Conversion.convertColors(primary));
        if (fade != null) fireworkBuilder.withFade(Conversion.convertColors(fade));
        if (flicker)      fireworkBuilder.withFlicker();
        if (trail)        fireworkBuilder.withTrail();

        fireworkMeta.addEffects(fireworkBuilder.build());
        firework.setFireworkMeta(fireworkMeta);
    }
View Full Code Here

        int power = Misc.getRandom().nextInt(3) + 1;
        Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
        double varX = Misc.getRandom().nextGaussian() * 3;
        double varZ = Misc.getRandom().nextGaussian() * 3;

        Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
        FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
        FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(fireworkType).trail(Misc.getRandom().nextBoolean()).build();
        fireworkmeta.addEffect(effect);
        fireworkmeta.setPower(power);
        fireworks.setFireworkMeta(fireworkmeta);
    }
View Full Code Here

    public static void fireworkParticleShower(Player player, Color color) {
        Location location = player.getLocation();
        location.setY(location.getY() + (player.isInsideVehicle() ? 1.0 : -1.0));
        location.setPitch(-90);

        Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK);
        FireworkMeta fireworkMeta = firework.getFireworkMeta();
        FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((Config.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build();
        fireworkMeta.addEffect(effect);
        fireworkMeta.addEffect(effect);
        fireworkMeta.setPower(0);
        firework.setFireworkMeta(fireworkMeta);
    }
View Full Code Here

                            FireworkEffect effect = FireworkEffect.builder().with(type).withColor(colour).withFade(fade).flicker(flicker).trail(trail).build();

                            if(!location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4))
                                continue;

                            Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
                            FireworkMeta meta = firework.getFireworkMeta();
                            meta.addEffect(effect);
                            meta.setPower((int) duration * 2);
                            firework.setFireworkMeta(meta);
                        } catch (Exception e) {
                            CraftBookPlugin.logger().severe("Error occured while doing: " + errorLocation + ". Whilst reading line " + position + " of the firework file " + showName + "!");
                            BukkitUtil.printStacktrace(e);
                        }
                    }
View Full Code Here

                        if(effects.containsKey(line.replace("launch ", ""))) {

                            if(!location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4))
                                continue;
                            final Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
                            FireworkMeta meta = firework.getFireworkMeta();
                            for(FireworkEffect effect : effects.get(line.replace("launch ", "")))
                                meta.addEffect(effect);
                            meta.setPower((int) duration * 2);
                            firework.setFireworkMeta(meta);
                            if(preciseDuration)
                                Bukkit.getScheduler().runTaskLater(CraftBookPlugin.inst(), new Runnable() {
                                    @Override
                                    public void run () {
                                        firework.detonate();
                                    }
                                }, (long) (duration*10));
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Firework

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.