isFlying() error?

Discussion in 'Spigot Plugin Development' started by Moderance, May 23, 2016.

  1. So I am using this code to check if a player is flying:

    Code (Text):
    if (sender.isFlying() == true) {
        } else {
    The problem is when they are in SURVIVAL mode it will error out in game 'An internal error occurred when attempting to perform this command' - It works if they are in CREATIVE although they can just double jump and then they're back into fly mode instead of typing /fly.


    I've also tried removing the == true, still same error.
  2. Why don't you just check for what game mode they're in?
  3. MiniDigger


    why not start with showing is the error at appered in your console?...
    • Like Like x 1
  4. Well, this shouldn't matter since isFlying(Boolean tF); is a Boolean.
    • Like Like x 1
  5. Use player.setAllowFlight(true); before enabling their flight.
    • Like Like x 2
  6. Ah, yes. Then set sender.setAllowFlight(false); when you set flying off
  7. When you see this error in game it means you need to look in cosolen to get detailed information about the issue. There will be a nice stacktrace outlining exactly what went wrong, and where.

    More information on how to read a stacktrace:
  8. Sorry just got back home,

    org.bukkit.command.CommandException: Unhandled exception executing command 'fly' in plugin Test
    at org.bukkit.command.PluginCommand.execute( ~[spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at org.bukkit.command.SimpleCommandMap.dispatch( ~[spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at org.bukkit.craftbukkit.v1_9_R1.CraftServer.dispatchCommand( ~[spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.PlayerConnection.handleCommand( [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.PlayerConnection.a( [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.PacketPlayInChat.a( [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.PacketPlayInChat.a( [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$ [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at java.util.concurrent.Executors$ Source) [?:1.8.0_91]
    at Source) [?:1.8.0_91]
    at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.MinecraftServer.D( [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.DedicatedServer.D( [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at net.minecraft.server.v1_9_R1.MinecraftServer.C( [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at [spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at Source) [?:1.8.0_91]
    Caused by: java.lang.IllegalArgumentException: Cannot make player fly if getAllowFlight() is false
    at org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer.setFlying( ~[spigot.jar:git-Spigot-e6f93f4-ed60c01]
    at test.moderance.commands.Fly.onCommand( ~[?:?]
    at org.bukkit.command.PluginCommand.execute( ~[spigot.jar:git-Spigot-e6f93f4-ed60c01]
    ... 15 more
  9. MiniDigger


    there you have your solution
    • Like Like x 1
  10. THANK YOU!

    Fixed, I better start reading the errors more :)

    edit: I have this weird glitch where if they are standing still and they do /fly it will always enable it for them?
  11. Standing on the group (not flying)
  12. @
    also u can check the error line : at test.moderance.commands.Fly.onCommand( ~[?:?]

    its very very usefull ^^
  13. Yeah did it a few hours ago I just replaced the if (isFlying()) with if (getAllowFlight == true)