How to check if player is flying

Discussion in 'Plugin Development' started by zorro1o1, Oct 17, 2013.

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

    zorro1o1

    Hello there
    I was wondering, how can i check if a player is flying?
    For example I can check the players gamemode:
    if ((ent instanceof Player)) {
    Player player = (Player)ent;
    if ((player.getGameMode() != GameMode.SURVIVAL) &&

    Could someone give me a code that can check IF a player is flying?
    Example
    if ((ent instanceof Player)) {
    Player player = (Player)ent;
    if ((player.isFlying() (i dont know what to type here :/)
     
  2. Offline

    _Filip

    player.isFlying() is the condition, it will return a boolean, just add a statement and you're set.
     
    zorro1o1 likes this.
  3. Offline

    mydeblob

    zorro1o1
    Code:java
    1. if(player.isFlying() == true){
    2. //Do what you want to do if the player is flying
    3. }
     
    zorro1o1 likes this.
  4. Offline

    zorro1o1

    Thanks alot! :D
     
  5. Offline

    _Filip

    Nonononono, remove the == true part, because if statesments only do things if the thing inside is true, player.isFlying() return true, doing player.isFlying() == true tells the if conditional "IF something that is TRUE is TRUE THEN" you only need to write player.isFlying().
     
  6. Offline

    AndyMcB1

    Just saying (which you might already know) you don't need to have the "== true"

    If you know this - just say so :p
     
  7. Offline

    zorro1o1

    eh eh eh Im confused o,o
    So what i want pretty much to happen is to say: IF the player is flying or have fly enabled, do this
     
  8. Offline

    AndyMcB1

    Yes, I was mainly replying to mydeblob

    An IF test will check if it's TRUE, so no need to specify that.
     
  9. Offline

    mydeblob

    AndyMcB1
    My bad, wasn't thinking there
     
    AndyMcB1 likes this.
  10. Offline

    zorro1o1

    Wait so whats the code o,o
     
  11. Hey there zorro1o1,

    The code is pretty straight forward, it can be one of those that were already posted:
    Code:java
    1. if(player.isFlying() == true){
    2. //Do what you want to do if the player is flying
    3. }
    4.  

    Or
    Code:java
    1. if(player.isFlying()){
    2. //Do what you want to do if the player is flying
    3. }
    4.  
     
  12. Offline

    zorro1o1

    umm okay thanks! if anyone has a different opinion plz post it :)
     
  13. Offline

    Hoolean

    zorro1o1

    There may be others but that is definitely the best way, as it uses Bukkit's API :)
     
  14. Offline

    zorro1o1

    Hoolean
    Hey Hoolean :D ty again for replying on one of my posts! You are really helpful and always active :D
     
Thread Status:
Not open for further replies.

Share This Page