Fireworks causing crashes?

Discussion in 'Plugin Development' started by bkleinman1, Nov 9, 2013.

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

    bkleinman1

    i have made a plugin that will spawn a firework if you right click and it will go in the direction your looking, im just wondering if there is something about the firework going straight along the ground, rather than in the air, is maybe causing the firework not to de-spawn, and it just continues going forever. I think this as i shoot about 3 off, then in about 20 seconds my game isnt responding.

    Any ideas why this is happening?

    thanks.
     
  2. Offline

    NoLiver92

    what is your code? posting the code will allow people to see whats wrong and help you
     
  3. Offline

    bkleinman1

    Code:java
    1. public void onPlayerInteract(PlayerInteractEvent event) {
    2. Player player = event.getPlayer();
    3. if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    4. if (player.getItemInHand().getType() == Material.DIAMOND_HOE) {
    5. Firework fw = (Firework) player.getWorld().spawn(player.getLocation(), Firework.class);
    6. FireworkMeta fm = fw.getFireworkMeta();
    7. fm.addEffect(FireworkEffect.builder().flicker(false).trail(true).with(Type.BALL).withColor(Color.RED).withFade(Color.BLUE).build());
    8. fm.setPower(1);
    9. fw.setFireworkMeta(fm);
    10. Location locFwd = player.getLocation().clone();
    11. Vector vecFwd = locFwd.getDirection();
    12. fw.setVelocity(vecFwd);
    13. }
    14. }
    15. }
     
Thread Status:
Not open for further replies.

Share This Page