When player stops moving, he dies

Discussion in 'Plugin Development' started by Zartixan, Aug 24, 2020.

  1. Offline

    Zartixan

    I wanted to make a plugin so whenever the player stopped walking or running, he would die. The problem is I don't know how to do it, so I'd aprecciate any help provided!
     
  2. Offline

    timtower Moderator Moderator

    @Zartixan Make a BukkitRunnable
    Loop over the players
    Get their velocity
    Turn the 3D thing into a single value (believe you can call .length)
    Kill if 0
     
  3. Offline

    Zartixan

    @timtower how do I make a bukkit runnable and do those stuff in it?
     
    Last edited: Aug 24, 2020
  4. Offline

    KarimAKL

    @Zartixan Make an anonymous class of BukkitRunnable, then override the run() method and do whatever you want.
     
  5. Offline

    Kars

  6. Offline

    jumbledProgram

    Hmm, maybe in the playermoveevent, put the player who moved in a hashmap as the key, and the value as the server current time in milliseconds/1000, and check in a runnable if the current time in milliseconds is the same as the player's value in the hashmap. use this: long time = System.currentTimeMillis()/1000; to get the current time in milliseconds. Im currently doing this, but when i turn it doesnt hurt the player :(. If anyone wants my code just task.
     
  7. Offline

    KarimAKL

    That'd be seconds, not milliseconds. You're dividing the milliseconds by 1000. :p Also, i believe the way @timtower mentioned is better.
     
  8. Offline

    Kars

    PlayerMovementEvent fires when the player looks around also.

    You'd be better off checking the player's position every second and if his current position is different from his last position, you hurt him. If that is what you are going for.

    Of course, using velocity would be better.
     
  9. Offline

    jumbledProgram

    well, when i tried to use velocity it only fired on the Y axis unless im propelled on the X or Z, it sadly doesnt work when walking
     
  10. Offline

    Kars

    @jumbledProgram just print all properties of velocity every second for yourself and walk around. See if you can determine how to do it from there.
     
  11. Offline

    jumbledProgram

    How would one go about doing this?
     
  12. Offline

    Kars

    @jumbledProgram getVelocity returns a Vector, which is a list. So print every entry of the list with broadcastMessage.
     
  13. Offline

    jumbledProgram

    Oh i know how to find velocity, im wondering on how i can get a players position and compare it a few ticks later
     
  14. Offline

    KarimAKL

    Why do you need that?

    Btw, why are you hijacking this thread? :p
     
  15. Offline

    jumbledProgram

    oops probably should make a new thread haha
     
  16. Offline

    Hatsonboats58

    You do realize that they can't craft right? Like nothing can be done. I am not saying it is a bad idea just suggesting a simple cooldown like 5 sec.
     
  17. Offline

    timtower Moderator Moderator

    If it is a certain gamemode where keeping moving is the way to win then they don't need to craft.
     

Share This Page