Event when player is falling

Discussion in 'Plugin Development' started by Kakarot798, Jul 21, 2015.

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


    Anyone know if an event fires with a player is falling? I think one does fire.

    I think it's PlayerVelocityEvent, but I'm not sure.
    This is what I have right now:
        public void noVoidFalling(PlayerVelocityEvent event){
            Player player = event.getPlayer();
            int pY = player.getLocation().getBlockY();
            if(pY <= 0){
                Location loc = player.getWorld().getSpawnLocation();
  2. Offline


  3. Offline


    PlayerVelocityEvent is only fired when a plugin or anything else sets the player's velocity to make them move. The correct way to do it is to listen to a
    And to see if they're falling, store the player and fall distance (it's a float) to a hashmap. Then everytime the move event is fired, check if their current fall distance is more than the one in your hashmap. Keep storing it until it hits a certain amount that you desire to execute an action upon.
    Shortninja66 likes this.
  4. Offline


    @Kakarot798 PlayerDamageEvent has a fonction DamageCause.Fall.
    But it's called once the player takes damage.
  5. @Kakarot798
    Because the PlayerMoveEvent fires so often, It would probably be better to create a task or scheduler to run ever 0.5 seconds or something.
  6. Offline


    considering that adding Objects to a Map shouldn't be time consuming, I see no problem with using @Agentleader1's method with the PlayerMoveEvent. However I would also check to make sure that the vector location is actually different.

    EDIT: You might not even need a HashMap depending on what you are using it for. You could just check the falling distance
    Last edited: Jul 21, 2015
  7. Offline


    if e.getTo().getY == 0
Thread Status:
Not open for further replies.

Share This Page