Solved PlayerMoveEvent

Discussion in 'Plugin Development' started by ewrs, Aug 26, 2018.

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

    timtower Administrator Administrator Moderator

    @ewrs Get rid of all timers.
    Just show the particles on the PlayerMoveEvent.
     
  2. Offline

    ewrs

    I need to show the parties if the player does not move ....

    w.spawnParticle(Particle.TOWN_AURA, p.getLocation().getX(), p.getLocation().getY() + 1, p.getLocation().getZ(), 150, 0.25, 0.50, 0.25, 0, null);
     
  3. Offline

    timtower Administrator Administrator Moderator

    Might want to use google translate then.
    Then you do need a timer indeed.
    https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/util/Vector.html#lengthSquared--
    That is a velocity check.
     
  4. Offline

    ewrs

  5. Offline

    timtower Administrator Administrator Moderator

    To see if the player is moving. You put it after the getVelocity and check if the value is 0
     
  6. Offline

    ewrs

    Can you throw me a diagram? I do not understand at all by pieces
     
  7. Offline

    timtower Administrator Administrator Moderator

    No, I won't.
    Try things, look at AFK plugins.
     
  8. Offline

    ewrs

    I can not understand their scheme. I asked you to explain, but apparently, you are lazy.
     
  9. Offline

    timtower Administrator Administrator Moderator

    Or maybe you just don't understand how I am explaining things. (also lazy, but that can also be a sign of a good programmer sometimes)
    There are multiple approaches to this issue.
    How accurate you want the standing still stuff to be is part of the reason which approach to use.

    You can use timers and check if the player is standing still by checking if the velocity of the player is 0.
    You can use a cooldown structure for the PlayerMoveEvent as well.
     
  10. Offline

    ewrs

    Can you tell me what to write in this timer and how to do the check? I expect help, not two incomprehensible words for me.

    How much I checked the speed, even if it's 0, nothing works!
     
  11. Offline

    timtower Administrator Administrator Moderator

    getVelocity().distanceSquared
    Print the speed, debug, look why it isn't working.

    And post what you are trying.
     
  12. Offline

    ewrs

    I did such a thing. Correctly?

    https://pastebin.com/cKby6kcY
     
  13. Offline

    timtower Administrator Administrator Moderator

    @ewrs Partially, now you start a timer for everybody that is online when the onEnable fires.
    Why not have 1 timer that runs all the time and checks all players?
     
  14. Offline

    ewrs

    I do not understand you. I have 1 timer ...

    And I have a question for you. How to make PlayerMoveEvent work when the player moves, and then when he moves his gaze
     
  15. Offline

    timtower Administrator Administrator Moderator

    Code:
    for (final Player p : Bukkit.getOnlinePlayers()) {
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    if(!AFK.containsKey(p.getName())) {
                        AFK.put(p.getName(), 1);
                    }else { PlayParticles(); }
                }
        }, 0, 5);
    This starts a timer for each player though. That is because the for loop is OUTSIDE the scheduleSyncRepeatingTask instead of inside where it should be.
     
  16. Offline

    ewrs

    Thanks, but I still do not understand why: D

    I have two more questions for you.

    1. How do I make for (final Player p: Bukkit.getOnlinePlayers ()) for the lined person

    2. Not quite on the topic. How can I make particles animation? As, for example, holo overhead
     
  17. Offline

    timtower Administrator Administrator Moderator

    @ewrs 1. I have no idea what you are trying to say.
    2. You are jumping the gun. Get it working and cleaned up first. And an example or something, because holo overhead doesn't say a lot to me.
     
  18. Offline

    ewrs

    1. For p = ewrs

    2. What ??
     
  19. Offline

    timtower Administrator Administrator Moderator

    @ewrs 1. And why would you need that?
    2. Make sure that this works before you start something new.
     
  20. Offline

    ewrs

    1. To be checked only for me.
    2. And where does the weapons in general? I just asked about the animation ...
     
  21. Offline

    timtower Administrator Administrator Moderator

  22. Offline

    ewrs

  23. Offline

    timtower Administrator Administrator Moderator

    @ewrs No, because a Player is not a String, you need to check the name.
    2. Because you are asking about the next step already without completing the ones in front. Finish this first, then continue.
     
  24. Offline

    ewrs

    It works successfully. So I asked about the particles
     
  25. Offline

    timtower Administrator Administrator Moderator

    Then please post an example image of what you want.
     
  26. Offline

    ewrs

    To over the player was a snake, which runs around in a circle (I'm talking about particles) Holo
     
  27. Offline

    timtower Administrator Administrator Moderator

    Image
     
  28. Offline

    ewrs

  29. Offline

    timtower Administrator Administrator Moderator

  30. Offline

    ewrs

    What is the principle of animation in general?
     
Thread Status:
Not open for further replies.

Share This Page