Get player location every second in another scheduler

Discussion in 'Plugin Development' started by coco5843, Jun 18, 2014.

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

    coco5843

    Hello , I have a problem ( french translation)

    So , I would like to find the location of a player every second and call it on another scheduler .
    But I can not do this :

    my code :

    Code:java
    1. int rotationId = Bukkit.getServer().getScheduler()
    2. .runTaskTimer(this, new Runnable()
    3. {
    4.  
    5. public void run()
    6. {
    7.  
    8. Location loc = p.getLocation(); //here I wan't like get location every second in a sheduler with every ticks
    9.  
    10. ParticleEffects.valueOf(particle).display(loc, 0.0F, 0.0F, 0.0F, 0.0F, 1);
    11.  
    12.  
    13. }
    14.  
    15. }
    16. }, 1L, 1L).getTaskId();
     
  2. Offline

    TheHandfish

    Why not just use the PlayerMoveEvent?
     
  3. Offline

    coco5843

    not given attention to the effect that I call because I simplified the code and I do not have to use player move event
     
  4. create a class that extends bukkitRunnable that saves the location every second. Also create a public method for it and use that in your second timer
     
  5. Offline

    TheHandfish

    Wait... so you're saying that your code is a lot more simple than the PlayerMoveEvent?

    Then why exactly are you having trouble? :p
     
  6. Offline

    coco5843

    I did not say that my code was simpler and I do not see why use the player move event
     
  7. Offline

    TheHandfish

    It's a built in function, and probably your best bet. Unless you want it to take more a second for the effects to be played, which would make sense.
     
  8. Offline

    coco5843

    TheHandfish
    you understand what I want to do? because the player move event is useless
     
  9. Offline

    TheHandfish


    Looking at your code, it appears that you want to display a particle effect to your player in a timed basis, rather than every time his location updates which would cause a bunch of lag, correct?

    Your initial post lead me to the conclusion you were trying to get his location for general purposes.
     
  10. Offline

    coco5843

    TheHandfish
    almost, I especially want the rotation effect ends without following the player
    when the player moves from one block , the effect should not follow but complete rotation
     
Thread Status:
Not open for further replies.

Share This Page