Permissions.

Discussion in 'Plugin Development' started by TheGamesHawk2001, Oct 29, 2014.

Thread Status:
Not open for further replies.
  1. If I had a command and I wanted different permissions to display a different msg when they typed the command. How would I do this?
     
  2. Offline

    es359

    TheGamesHawk2001 likes this.
  3. es359 Nothing, I'm going to use this as a reference when I get home.

    I'll use this probs:

    if (cmd.getName.equalsinorecase ("commands");
    sender.sendMessage("abc");
    sender.sendMessage("rty");

    How wud I make it so if they had a perm cheese.a it would only display the "rty" msg and a different perm for the "ABC" msg
    I'm on phone so..lol
     
    es359 likes this.
  4. Offline

    es359

    Check to see what permission the sender has, if they have the permission for abc, send them abc, if they have the permission for rty, send them rty. TheGamesHawk2001
     
  5. Do I just put another permission above the msg I want to send the person with that perm?
     
  6. Offline

    es359

    No, because it will just run anyway, you have to check it using an if() statement.

    Code:java
    1. if(sender.hasPermission("perm")) {
    2. //do thing
    3. }
     
  7. es359 I meant that when I said another permission lol. Thanks :)
     
  8. Offline

    es359

    TheGamesHawk2001 You would want to use an else if then for that.

    Code:java
    1. if(cmd.getName().equalsIgnoreCase("yourcommand")) {
    2. if(p.hasPermission("somepermission1")) {
    3. //send that message.
    4. }else if(p.hasPermission("someotherpermission2")) {
    5. //send that message.
    6. }
    7. }
     
  9. es359 Ahh, so "else if" is if there's more than 1 permission for each method, can't really describe it that well xD
     
Thread Status:
Not open for further replies.

Share This Page