Freeze players except who is falling

Discussion in 'Plugin Development' started by Luca0098, Dec 22, 2013.

Thread Status:
Not open for further replies.
  1. Hello!

    I am making a plugin where it listens for a PlayerMoveEvent, and if a variable Stop is true, it freezes the players. I know that there are two ways to do it: the first is to cancel the event, and the second is to teleport the player to the player.

    As my plugin involves parkour, it may happen that a player is falling while Stop is being set to true. What I want to do is basically to don't freeze the player when he's falling, mainly because it may get kicked for flying.

    The problem is that there is not a method to check if the player is falling.
    How can I detect it?
     
  2. Offline

    xTigerRebornx

    Luca98 Detect if their Y level is decreasing, and if the block below them is air (or whatever they are falling into?)
     
  3. xTigerRebornx Will try.

    Also, do you guys think it's better to cancel the event or teleport player to player to freeze a player?
     
  4. Offline

    Gater12

    Luca98 Cancel the event. Little buggers can sneak one pixel at a time if you keep teleporting to their location.
     
  5. Offline

    xTigerRebornx

    Gater12 Luca98 I agree with Gater, teleporting the player to themself will slowly increase them in the direction
     
  6. Offline

    jusjus112

    Luca98
    You can check if the player is on the ground?
    Code:java
    1. if (p.isOnGround()) {
    2. // Do stuff
    3. }
     
  7. jusjus112 It would be perfect, but it is deprecated :/
     
  8. Offline

    Fedmand

    Code:
    @EventHandler
    void onMovement(PlayerMoveEvent event) {
    for (Player allPlayers : Bukkit.getOnlinePlayers()) {
    // this will loop through all players on the server
    if (Stop && player.isOnGround()) {
    // This will check if the players are on the ground and if the
    // "Stop" variable is "true"
    event.setCancelled(true);
    // This will cancel the movent of those who are on the ground
    }
    }
    }
    
    I hope this was helpful!
     
  9. Fedmand Player.isOnGround() is deprecated.
     
  10. Offline

    Not2EXceL

    Just check if their Y velocity < 0. If so don't freeze.
     
Thread Status:
Not open for further replies.

Share This Page