Firework on join

Discussion in 'Plugin Development' started by BlazeEyezz, Jul 5, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    BlazeEyezz

    Hello guys,
    I want to make, when a player joins, there spawn three pieces of firework.
    Until now, i just get 1 piece of firework :l
    Can someone help me?
    Here's my code:

    Code:java
    1. @EventHandler
    2. public void Join(PlayerJoinEvent e){
    3. Player p = e.getPlayer();
    4. Location l = new Location(p.getWorld(), -63.01, 79.05, -243.02);
    5. Location m = new Location(p.getWorld(), -52.82, 63.05, -161.02);
    6. Location r = new Location(p.getWorld(), -74.82, 63.05, -161.02);
    7. Firework fw = (Firework)p.getWorld().spawnEntity(l, EntityType.FIREWORK);
    8. Firework fw2 = (Firework)p.getWorld().spawnEntity(l, EntityType.FIREWORK);
    9. Firework fw3 = (Firework)p.getWorld().spawnEntity(l, EntityType.FIREWORK);
    10. FireworkMeta fwm = fw.getFireworkMeta();
    11. FireworkEffect sphere = FireworkEffect.builder().withColor(Color.GREEN).with(FireworkEffect.Type.BALL_LARGE).build();;
    12. fwm.addEffect(sphere);
    13. fwm.setPower(1);
    14. fw.setFireworkMeta(fwm);
    15. }


    Thnx!
     
  2. Offline

    fireblast709

    BlazeEyezz And what is wrong with the other two? Not getting fancy effects? That is because you only gave one a colour and a shape.
     
  3. Offline

    BlazeEyezz

    Those firework just don't spawn.
     
  4. Offline

    fireblast709

    BlazeEyezz you spawned all three at location l
     
  5. Offline

    mine-care

    I think they actually spawn but they have no fwk effect on them so they can't be seen
    And (I might be false but) why you have double ;; after the fork effect ( line 11 )
     
  6. Offline

    BlazeEyezz

    It's not that there arn't any Firework effects, but there is just one firework :l

    My code now:

    Code:java
    1. @EventHandler
    2. public void Join(PlayerJoinEvent e){
    3. Player p = e.getPlayer();
    4. Location l = new Location(p.getWorld(), -52.01, 79.05, -243.02);
    5. Location m = new Location(p.getWorld(), -63.82, 86.05, -243.02);
    6. Location r = new Location(p.getWorld(), -74.82, 79.05, -243.02);
    7. Firework fw = (Firework)l.getWorld().spawnEntity(l, EntityType.FIREWORK);
    8. Firework fw2 = (Firework)m.getWorld().spawnEntity(l, EntityType.FIREWORK);
    9. Firework fw3 = (Firework)r.getWorld().spawnEntity(l, EntityType.FIREWORK);
    10. FireworkMeta fwm = fw.getFireworkMeta();
    11. FireworkEffect sphere = FireworkEffect.builder().withColor(Color.GREEN).with(FireworkEffect.Type.BALL_LARGE).build();
    12. FireworkEffect effect = FireworkEffect.builder().withColor(Color.WHITE).with(FireworkEffect.Type.BALL).build();
    13. fwm.addEffect(sphere);
    14. fwm.addEffect(effect);
    15. fwm.setPower(1);
    16. fw.setFireworkMeta(fwm);
    17. }
     
  7. Offline

    AoH_Ruthless

    BlazeEyezz
    You are only adding effects and setting power to one firework ...
     
    MCMastery likes this.
  8. Offline

    gal0511Dev

    BlazeEyezz
    Im doing this with no eclipse so no promise it works
    Code:java
    1. @EventHandler
    2. public void Join(PlayerJoinEvent e){
    3. Player p = e.getPlayer();
    4. Location l = new Location(p.getWorld(), -52.01, 79.05, -243.02);
    5. Location m = new Location(p.getWorld(), -63.82, 86.05, -243.02);
    6. Location r = new Location(p.getWorld(), -74.82, 79.05, -243.02);
    7. Firework fw = (Firework)l.getWorld().spawnEntity(l, EntityType.FIREWORK);
    8. Firework fw2 = (Firework)m.getWorld().spawnEntity(l, EntityType.FIREWORK);
    9. Firework fw3 = (Firework)r.getWorld().spawnEntity(l, EntityType.FIREWORK);
    10. FireworkMeta fwm = fw.getFireworkMeta();
    11. FireworkMeta fwm2 = fw2.getFireworkMeta();
    12. FireworkMeta fwm3 = fw3.getFireworkMeta();
    13. FireworkEffect sphere = FireworkEffect.builder().withColor(Color.GREEN).with(FireworkEffect.Type.BALL_LARGE).build();
    14. FireworkEffect effect = FireworkEffect.builder().withColor(Color.WHITE).with(FireworkEffect.Type.BALL).build();
    15. fwm.addEffect(sphere);
    16. fwm.addEffect(effect);
    17. fwm.setPower(1);
    18. fw.setFireworkMeta(fwm);
    19.  
    20. fwm2.addEffect(sphere);
    21. fwm2.addEffect(effect);
    22. fwm2.setPower(1);
    23. fw2.setFireworkMeta(fwm2);
    24.  
    25. fwm3.addEffect(sphere);
    26. fwm3.addEffect(effect);
    27. fwm3.setPower(1);
    28. fw3.setFireworkMeta(fwm3);
    29.  
    30.  
    31. }
     
  9. Offline

    AoH_Ruthless

    gal0511
    Too much spoonfeeding for my eyes.
     
  10. Offline

    DeanAyalon

    Hey,
    as fireblast said, you have Spawned all of the Fireworks at the same Location

    Firework fw = (Firework)l.getWorld().spawnEntity(l, EntityType.FIREWORK);
    Firework fw2 = (Firework)m.getWorld().spawnEntity(l, EntityType.FIREWORK);
    Firework fw3 = (Firework)r.getWorld().spawnEntity(l, EntityType.FIREWORK);

    I think thats the Problem
     
Thread Status:
Not open for further replies.

Share This Page