Solved Player.setFlying() having issues.

Discussion in 'Plugin Development' started by ThePandaPlayer, Jun 14, 2018.

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


    Good day,

    I am having trouble with the Player.setFlying() method.

    My code:
    Player p = (Player) sender;
            if(p.isFlying()) {
                if(p.getGameMode().equals(GameMode.SURVIVAL)||p.getGameMode().equals(GameMode.ADVENTURE)) {
                p.sendMessage(flyHeader+ChatColor.DARK_PURPLE+"You are no longer flying.");
                return 0;
            else {
                p.sendMessage(flyHeader+ChatColor.DARK_PURPLE+"You are now flying.");
                return 0;
    Now, when I run this in any Game Mode, I do fly for a split second, then it almost instantly sets me back on the ground with no error message. I have double checked all of my installed plugins (just PEX and FAWE) and found none of them blocking flight.

    Another strange oddity is that if I am falling and I run the command, I immediately stop falling and I am flying like I expected the command to do before. What is happening?

    (Please note that the return statements are correct. I have my own special command parsing system that allows me to return error codes.)
  2. Offline


    I apologize mod for double posting, I am having a legitimate issue with no responses.
  3. Offline


    Try removing all other plugins from your server. Does the problem still occur?
  4. Offline


    I have done exactly what you have told me to do.

    I still get the same strange behavior.

    When I run my /fly command, it works just fine. However, I am only flying for a split second before it immediately sets my player back on the ground. Also, the server will not allow me double jump again, (if I'm in Gamemode 0 or 2)
    even though in my code, I set Player.setAllowFlight to true. I feel like this is something with the Server.
  5. Online

    timtower Moderator Moderator

  6. Offline


    I just realized something.

    So it turns out I CAN double jump to start flying again.
    However, that is not the intended functionality.
    The intended functionality is that my /fly command will set the player flying and unable to stop.
    When the command is run again, the player will be dropped back to the ground.

    And yes @timtower it is.

    Again, sorry for double post, I really need this issue solved.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 16, 2018
  7. Offline


    Is it messaging you when you go back to the ground saying you are no longer flying?
  8. Offline


    No. It simply cancels the flight.

    Also, I tried a different version of Spigot (1.8.8) and got the same behavior.
  9. Offline


    Well in my fly command I just flipped the Player#getAllowedFlight() method and set that to the allowed flight and setFlying and it works with me. Maybe instead of doing isFlying use getAllowedFlight
  10. Offline



    I'll give that a try.


    So I just checked through my settings, as I was still getting the strange behavior. However, after a bit of googling I found that I had missed a setting inside of my file. The setting "allow-flight" was false... I'm such an idiot. XD
    Thank you all for your help though!
    Last edited: Jun 28, 2018
Thread Status:
Not open for further replies.

Share This Page