Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. int id = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  2.             @Override
  3.             public void run() {
  4.                 final List<Location> locations = (ArrayList<Location>) createCircle(p.getLocation(), 5);
  5.                
  6.                 for (int i = 0; i < locations.size(); i++) {
  7.                     final int j = i;
  8.                     Bukkit.getScheduler().scheduleSyncDelayedTask(Main.this, new Runnable() {
  9.                         @Override
  10.                         public void run() {
  11.                             //Spawn the Firework, get the FireworkMeta.
  12.                             Firework fw = (Firework) p.getWorld().spawnEntity(locations.get(j), EntityType.FIREWORK);
  13.                             FireworkMeta fwm = fw.getFireworkMeta();  
  14.  
  15.                             //Get the type
  16.                             int rt = r.nextInt(4) + 1;
  17.                             Type type = Type.BALL;      
  18.                             if (rt == 1) type = Type.BALL;
  19.                             if (rt == 2) type = Type.BALL_LARGE;
  20.                             if (rt == 3) type = Type.BURST;
  21.                             if (rt == 4) type = Type.CREEPER;
  22.                             if (rt == 5) type = Type.STAR;
  23.                        
  24.                             //Get our random colors  
  25.                             Color c1 = Color.fromBGR(r.nextInt(255), r.nextInt(255), r.nextInt(255));
  26.                             Color c2 = Color.fromBGR(r.nextInt(255), r.nextInt(255), r.nextInt(255));
  27.                        
  28.                             //Create our effect with this
  29.                             FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
  30.                        
  31.                             //Then apply the effect to the meta
  32.                             fwm.addEffect(effect);
  33.                        
  34.                             //Generate some random power and set it
  35.                             //int rp = r.nextInt(2) + 1;
  36.                             //fwm.setPower(rp);
  37.                        
  38.                             //Then apply this to our rocket
  39.                             fw.setFireworkMeta(fwm);
  40.                         }
  41.                     }, i * (8 * 20L / locations.size()) );
  42.                 }
  43.             }
  44.         }, 0L, 8 * 20L);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement