Stop a player from falling

Discussion in 'Plugin Development' started by HeyStu, May 17, 2013.

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

    HeyStu

    Is there a good way to prevent a player from falling for the next 5 seconds?

    By 'good' I mean lightweight, e.g. I don't really want to set a listener for every move event if possible.

    Thanks
     
  2. Offline

    Craftiii4

    set them into fly mode? then remove?
     
  3. Offline

    Iervolino

    Code:java
    1. @EventHandler
    2. public void onEntityDamage(EntityDamageEvent event) {
    3. if (!(event.getEntity() instanceof Player)) return;
    4. if ((event.getCause().equals(EntityDamageEvent.DamageCause.FALL)))
    5. event.setCancelled(true);
    6. }
     
  4. Offline

    Craftiii4

    I'm pretty sure he is asking how to stop a playing falling, not how to stop fall damage?.
     
  5. Offline

    Iervolino

    p s e u d o
     
  6. Offline

    Craftiii4

    lol, So you just assumed he was talking about something else I take it then.

    You could be right, but if you are then the question has poor English.
     
  7. Offline

    HeyStu

    Nah, I was talking about stopping a player from falling, i.e. the title of the question.

    Fly mode might be a good option, thanks. Just need to find a solid way of ensuring it is removed from them in 5 seconds (e.g. even if server restarts, or they log out).
     
  8. Offline

    Craftiii4

    Add them to a list, if they log out, set fly mode to off and remove from list. If server restarts, get everyone in list, set all to fly mode off.
     
  9. Offline

    HeyStu

    Sorry for the noobish question, but can fly mode be turned off even if they are offline?
     
  10. Offline

    Jalau

    If you don't save the players name to a list his fly mode should go off if he reconnects, if not you can check for fly mode on joinevent and turn it off if it response true...
     
  11. Offline

    Craftiii4

    If you catch it as they log off, it should work fine I think :3

    Well, if he set the flymode to turn off after 5 seconds, if they were not online after 5 seconds it won't be turned off.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  12. Offline

    Jalau

    Then he can check as i already mentioned on the join event for flymode of each player...
     
  13. Offline

    Craftiii4

    You fail to remember that some people might legit-ly have flight mode or be in gamemode.
     
  14. Offline

    Jalau

    No i didn't ^^ It's just the easiest way to do it...
     
  15. Offline

    Craftiii4

    But it would not work in all situations :p
     
Thread Status:
Not open for further replies.

Share This Page