Solved "Cannot make player fly if getAllowFlight() is false"

Discussion in 'Plugin Development' started by caseif, Jul 30, 2014.

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


    Can someone please explain to me why
    1. if (Bukkit.getAllowFlight()){
    2. p.setFlying(true);

    throws this exception?
    Caused by: java.lang.IllegalArgumentException: Cannot make player fly if getAllowFlight() is false
        at org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer.setFlying(
        at net.amigocraft.mglib.api.MGPlayer.setSpectating(
        at net.amigocraft.ttt.listeners.MGListener.onMGPlayerDeath(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        ... 31 more
    Because I am not okay with this.

    Yes, allow-flight is true in, and yes, this is definitely the code throwing the exception.
  2. Offline


    ShadyPotato getPlayer().setAllowFlight(true);
  3. Offline


    Ohhhhh gotcha.
  4. Offline


    Afaik there should be a p.setAllowFlight() to, however I think the difference is when its enabled in the config that it is ment against kicking and p.setAllowFlight() is ment to allow the player to fly though I don't really see a reason why it should throw a exception unless both count the same, however p.setAllowFlight() fixes the exception if you put it before you set the player to fly.
Thread Status:
Not open for further replies.

Share This Page