Solved Player.setFlying() having issues.

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

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

    ThePandaPlayer

    Good day,

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

    My code:
    Code:
    Player p = (Player) sender;
           
            if(p.isFlying()) {
                p.setFlying(false);
                if(p.getGameMode().equals(GameMode.SURVIVAL)||p.getGameMode().equals(GameMode.ADVENTURE)) {
                    p.setAllowFlight(false);
                }
                p.sendMessage(flyHeader+ChatColor.DARK_PURPLE+"You are no longer flying.");
                return 0;
            }
            else {
               
                p.setAllowFlight(true);
                p.setFlying(true);
                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

    ThePandaPlayer

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

    Zombie_Striker

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

    ThePandaPlayer

    @Zombie_Striker
    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 Administrator Administrator Moderator

  6. Offline

    ThePandaPlayer

    @Zombie_Striker
    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

    CommonSenze

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

    ThePandaPlayer

    @CommonSenze
    No. It simply cancels the flight.

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

    CommonSenze

    @ThePandaPlayer
    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

    ThePandaPlayer

    @CommonSenze

    I'll give that a try.

    EDIT:

    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 server.properties 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