Exemplo n.º 1
0
 /** @return the type */
 public Type getType() {
   if (type == null) {
     return Type.values()[r.nextInt(Type.values().length)];
   } else {
     return type;
   }
 }
Exemplo n.º 2
0
 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);
 }