public static void shootRandomFirework(Location loc, int height) { Firework f = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK); FireworkMeta fm = f.getFireworkMeta(); fm.setPower(height); int effectAmount = random.nextInt(3) + 1; for(int i = 0; i < effectAmount; i++) { Builder b = FireworkEffect.builder(); int colorAmount = random.nextInt(3) + 1; for(int ii = 0; ii < colorAmount; ii++) { b.withColor(Color.fromBGR(random.nextInt(256), random.nextInt(256), random.nextInt(256))); } b.with(Type.values()[random.nextInt(Type.values().length)]); b.flicker(random.nextInt(2) == 0 ? false : true); b.trail(random.nextInt(2) == 0 ? false : true); fm.addEffect(b.build()); } f.setFireworkMeta(fm); }
@Override public void onRun() { if (firework == null) { Builder b = FireworkEffect.builder().with(fireworkType); b.withColor(color).withColor(color2).withColor(color3); b.withFade(fadeColor); b.trail(true); firework = b.build(); } Location location = getLocation(); for (int i = 0; i < explosions; i++) { Vector v = RandomUtils.getRandomVector().multiply(radius); detonate(location, v); if (soundInterval != 0 && step % soundInterval == 0) { location.getWorld().playSound(location, sound, soundVolume, soundPitch); } } step++; }
/** * Launch a firework at a given location with specified properties * * @param spawnLocation the location for the firework * @param type the firework type * @param power the power of the firework * @param colors the colors of the fireworks * @param fadecolors the colors for the firework to fade to * @param trail if the firework should leave a trail * @param flicker if the firework should flicker */ static public Firework LaunchFirework(Location spawnLocation, FireworkEffect.Type type, int power, ArrayList<Color> colors, ArrayList<Color> fadecolors, boolean flicker, boolean trail) { Firework firework = spawnLocation.getWorld().spawn(spawnLocation, Firework.class); FireworkMeta metadata = firework.getFireworkMeta(); Builder builder = FireworkEffect.builder(); builder.with(type); builder.flicker(flicker); builder.trail(trail); builder.withColor(colors); builder.withFade(fadecolors); FireworkEffect effect = builder.build(); metadata.addEffect(effect); metadata.setPower(power); firework.setFireworkMeta(metadata); return firework; }
/** * Launches firework when receiving an achievement. * * @param player */ private void displayFirework(Player player) { Location location = player.getLocation(); try { // Set firework to launch beneath user. location.setY(location.getY() - 1); Firework firework = player.getWorld().spawn(location, Firework.class); FireworkMeta fireworkMeta = firework.getFireworkMeta(); Builder effectBuilder = FireworkEffect.builder().flicker(false).trail(false) .withColor(Color.WHITE.mixColors(Color.BLUE.mixColors(Color.NAVY))).withFade(Color.PURPLE); setFireworkType(effectBuilder); fireworkMeta.addEffects(effectBuilder.build()); firework.setVelocity(player.getLocation().getDirection().multiply(0)); firework.setFireworkMeta(fireworkMeta); // Firework launched by plugin: damage will later be cancelled out. plugin.getFireworkListener().addFirework(firework); } catch (Exception e) { // Particle effect workaround to handle various bugs in early Spigot 1.9 and 1.11 releases. We try to // simulate a firework. player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_LAUNCH, 1, 0.6f); ParticleEffect.FIREWORKS_SPARK.display(0, 3, 0, 0.1f, 500, location, 1); player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_BLAST, 1, 0.6f); player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_TWINKLE, 1, 0.6f); } }
/** * Sets the type of the firwrok, which can either be predefined or random. * * @param effectBuilder */ private void setFireworkType(Builder effectBuilder) { if ("RANDOM".equalsIgnoreCase(configFireworkStyle)) { Type[] fireworkTypes = Type.values(); effectBuilder.with(fireworkTypes[RANDOM.nextInt(fireworkTypes.length)]); } else { try { effectBuilder.with(Type.valueOf(configFireworkStyle.toUpperCase())); } catch (Exception e) { effectBuilder.with(Type.BALL_LARGE); plugin.getLogger().warning( "Failed to load FireworkStyle. Please use one of the following: BALL_LARGE, BALL, BURST, CREEPER or STAR."); } } }
public void addEffect(Type type, Color color, boolean withFlicker) { Builder builder = FireworkEffect.builder() .with(type) .withColor(color); if(withFlicker) builder = builder.withFlicker(); effects.add(builder.build()); }
public void spawnFireworks(final Team team) { BukkitScheduler bc = Bukkit.getScheduler(); long delay = 10L; int amount = (int) ((20L / delay) * 30); for(int i = 0; i < amount; i++) bc.scheduleSyncDelayedTask(Breakpoint.getInstance(), new Runnable() { @Override public void run() { Firework fw = PlayerManager.spawnFirework(getSpawnLocation(team)); FireworkMeta fm = fw.getFireworkMeta(); Random rnd = new Random(); Color[] colors = new Color[3]; fm.setPower(1 + rnd.nextInt(3)); if(team == Team.RED) { colors[0] = Color.RED; colors[1] = Color.ORANGE; colors[2] = Color.YELLOW; } else if(team == Team.BLUE) { colors[0] = Color.BLUE; colors[1] = Color.AQUA; colors[2] = Color.NAVY; } for(int i = 0; i < (1 + rnd.nextInt(5)); i++) { Builder fe = FireworkEffect.builder(); fe = fe.flicker(rnd.nextBoolean()); fe = fe.trail(rnd.nextBoolean()); fe = fe.with(FireworkEffect.Type.values()[rnd.nextInt(5)]); List<Color> color = new ArrayList<Color>(); List<Color> fade = new ArrayList<Color>(); for(int j = 0; j < (1 + rnd.nextInt(3)); j++) color.add(colors[rnd.nextInt(3)]); for(int j = 0; j < (1 + rnd.nextInt(3)); j++) fade.add(colors[rnd.nextInt(3)]); fe = fe.withColor(color); fe = fe.withFade(fade); fm.addEffect(fe.build()); } fw.setFireworkMeta(fm); } }, delay * i); }
public void spawnTrappedEgg() { eggLocation.getBlock().setType(Material.DRAGON_EGG); // Spawning fireworks twice because it doesn't always works on the first try… for(int i = 0; i < 2; i++) { Firework fw = (Firework) eggLocation.getWorld() .spawnEntity(eggLocation.clone().add(0.5, 1, 0.5), EntityType.FIREWORK); FireworkMeta meta = fw.getFireworkMeta(); Builder builder = FireworkEffect.builder() .with(Type.BALL) .withColor(Color.fromRGB(0x08080c)); meta.addEffect(builder.build()); builder = FireworkEffect.builder() .with(Type.BALL) .withColor(Color.fromRGB(0x2d0133)); meta.addEffect(builder.build()); meta.setPower(1); fw.setFireworkMeta(meta); fw.detonate(); } for(Player player : Bukkit.getOnlinePlayers()) player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1); StringBuilder msg = new StringBuilder(); msg.append("["); msg.append(ChatColor.DARK_PURPLE + "ENDERDRAGON"); msg.append(ChatColor.WHITE + "] "); msg.append(ChatColor.RED + "Vous pensiez vous être débarrassé de moi ?"); Bukkit.broadcastMessage(msg.toString()); msg = new StringBuilder(); msg.append("["); msg.append(ChatColor.DARK_PURPLE + "ENDERDRAGON"); msg.append(ChatColor.WHITE + "] "); msg.append(ChatColor.DARK_RED + "Je vous attends où vous auriez dû me déposer..."); Bukkit.broadcastMessage(msg.toString()); String msgHelp = "Noobs : Rendez-vous en x=" + eggLocation.getBlockX() + ", z=" + eggLocation.getBlockZ(); RftdLogger.broadcast(Level.INFO, msgHelp); trappedEgg = true; // Start sound between 3 seconds (60 ticks) and 5 seconds (100 ticks) long nextTick = Math.round(Math.random() * 40) + 60; Bukkit.getScheduler().runTaskLater(plugin, new TrappedEggSoundTask(), nextTick); }
public static FireworkEffect.Builder builder() { return null; }
public Builder with(Type type) throws IllegalArgumentException { return null; }
public Builder withFlicker() { return null; }
public Builder withTrail() { return null; }
public Builder withColor(Color color) throws IllegalArgumentException { return null; }
public Builder withColor(Color... colors) throws IllegalArgumentException { return null; }
public Builder withColor(Iterable<?> colors) throws IllegalArgumentException { return null; }
public Builder withFade(Color color) throws IllegalArgumentException { return null; }
public Builder withFade(Color... colors) throws IllegalArgumentException { return null; }
public Builder withFade(Iterable<?> colors) throws IllegalArgumentException { return null; }