Solved Fly Else Code Permission

Discussion in 'Spigot Plugin Development' started by TpittGamez, May 29, 2016.

  1. Hello I was wondering if anyone knew how to set a permission on an else statement, My coding is below. Thank you!
     
    #1 TpittGamez, May 29, 2016
    Last edited: May 29, 2016
  2. ? I'm not sure what you mean?

    Do you mean -
    Code (Text):
    if (p.hasPermission("PERM)) {
    //DO SOMETHING
    } else {
    //IF THEY DON'T HAVE IT
    }
    Please explain more
     
  3. Yes if they don't have the perm it will give an error message and if they do they can do /fly on or off
     
  4. Code (Text):
    // player does /fly
        if(player.hasPermission("fly.use")) {
            // do fly stuff
        } else {
            // no permission
        }
    }
     
  5. @TpittGamez okay so try this, (or what @Cewlt said)

    Code (Text):
    if (player.hasPermission("fly.use)) {
    //Do the fly stuff
    } else {
    p.sendMessage("You do not have permission to do this");
    }
     
  6. ok but where would I put the command name
     
  7. @TpittGamez its up to you, it doesn't effect either way. IMO it looks nicer but it doesn't matter
     
  8. Also how would I keep it so I don't need to do /fly on and /fly off and just need to do /fly (sorry I am kind of new to the /fly command coding)
     
  9. Sorry, but you dont seem to understand anything. You should at least know how coding generally works. We gave you enough answers and you should know how to implement it.
     
    • Agree Agree x 1
  10. I am just new to else statements I can do the coding for it I just don't know where to put the permission in. All I ned to know is where to put the permission statement in:
    Code (Text):
    if (!sender.hasPermission("fly.use")) {
    and where it would go in the coding, because if I put it under
    Code (Text):
    if (cmd.getName().equalsIgnoreCase("fly"))
    I get an error
     
    • Funny Funny x 1
  11. New to else statements......................................................................................................................
    I give up
     
  12. Fixed it, thanks for the help!
     
  13. No problem @TpittGamez, if you need any more help just tag me in your post!