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

    caseif

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

    throws this exception?
    Code:
    Caused by: java.lang.IllegalArgumentException: Cannot make player fly if getAllowFlight() is false
        at org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer.setFlying(CraftPlayer.java:1132)
        at net.amigocraft.mglib.api.MGPlayer.setSpectating(MGPlayer.java:170)
        at net.amigocraft.ttt.listeners.MGListener.onMGPlayerDeath(MGListener.java:357)
        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)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292)
        ... 31 more
    Because I am not okay with this.

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

    ResultStatic

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

    caseif

    Ohhhhh gotcha.
     
  4. Offline

    xize

    ShadyPotato
    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