Solved Can I activate fly mode on air someway

Discussion in 'Spigot Plugin Development' started by iTweakz, May 30, 2017.

Thread Status:
Not open for further replies.
  1. Yes so is it possible to activate fly mode on air when you are example falling down without double pressing space button ?
     
  2. Yes its possible?
     
  3. How its possible? :)
     
  4. Here's the code you need:

    Code (Java):

    player.setFlying(true);
     
     
  5. Oh thanks dude :)
     
  6. Since when did this exist? Never saw it before
     
  7. Here's a code when you're actually falling;

    public static boolean isFalling(Player p, Location from, Location to) {
    double d = from.getY() - to.getY();
    if (d <= 0.0D) {
    return false;
    }
    p.setFlying(true);
    return true;
    }
     
  8. Weird method. Personally, when I see a boolean, it should check the state, not execute methods. I generally use other methods for that cause, just for clarity and readability reasons.
     
  9. Well if it's true then what the point in making it in another class, just an example though.
     
  10. I didn't say to put it in another class.
    For example, if I have this method:
    Code (Text):
        public static void evaluateFlying(Player p, Location from, Location to) {
            if (!isFalling(p, from, to)) return;
            p.setFlying(true);
        }
    Just reads better. That way you know, that if whatever method the OP decides to use for evaluating to check to see if the player is falling, in this case I simply just used an evaluateFlying method, you know the method checks to see if the player is falling, and if the player isn't, then it will set their flying to true.
     
  11. Set the isAbleFlight(true) when in lobbies only I guess
     
  12. I love how a lot of the people on this site are so pretentious. It's like they learned a bit of java, and now helping someone else without being a dick about it would somehow diminish their own programming skills or deduct from any work they have put in learning, pretending they never got helped in the first place when they were learning.

    Back to the question.

    You've been shown how to toggle flying and how to tell if someone is falling. I've done this before and found adding in a check to see if a few blocks below the player are air helps too, otherwise it gets rather annoying with it toggling flying on a lot of the time when you are just dropping down a few blocks.
     
Thread Status:
Not open for further replies.