Discussion in 'Spigot Plugin Development' started by HydroTekZ, May 3, 2015.

  1. How can I detect if a player jumps? I need to log each time a player jumps. Please say there is an event for this.
  2. I'm sure playermoveevent and you can check if they're on the ground or not.
  3. Yeah, but I don't wanna know if the player is on the ground or not, I want to know how often they jump. I don't really think PlayerMoveEvent would be a great way of doing that.
  4. That would probably get activated way to much. Like every time someone looks around while jumping/falling. Resulting in possibly dozens of 'jumps' in one actual jump.
    I don't think there is a way to easily and accurately get this.. Jumping is mostly client side
    • Agree Agree x 1
    • Funny Funny x 1
  5. Code (Java):
    public void onPlayerMove(PlayerMoveEvent e) {
    if(e.getFrom().getY() < e.getTo().getY() && e.getPlayer().getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR) {
    // Player has jumped.
    Literally just took a Google search containing "PlayerJumpEvent" ;)
    • Like Like x 1
  6. .... Wasn't too hard see.
  7. gigosaurus


    Don't do that, as that is just checking that a player's Y value has increased. Check that they were originally on the ground and that they aren't riding something. Somehow detecting if they were knocked back could also be helpful.
    #7 gigosaurus, May 3, 2015
    Last edited: May 3, 2015
  8. You'd have to check if they're flying or riding as well.
  9. What if the player have jump effect? I don't think that will work great.
  10. Add some sort of list if they've touched the ground after a first call.. (and check it)
  11. Do a PlayerMoveEvent and check if the e.getTo().getY() > e.getFrom().getY()
    • Like Like x 1
  12. There is no jump event, you will need to listen for the move event and manually check if the player jumped.
  13. There isn't jump event!