Having problems adding permissions to my plugin

Discussion in 'Plugin Development' started by jordanzilla02, Oct 20, 2013.

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

    jordanzilla02

    I started developing a banning plugin and am having trouble adding permissions into it. I have hasPermission(ZillaBans.ban) and (ZillaBans.kick). I have read pretty much all I could read about making permissions in bukkit. This is my first plugin and I am quite new to the bukkit api. Thank you please help.
    Here is a pastebin of my code and I will provide a download if you need to see the jar. Thanks again. http://pastebin.com/GFuwinBe
     
  2. Offline

    PolarCraft

    You would do the following.
    Code:java
    1. if (sender.hasPermission("example.test")) {
     
  3. Offline

    1Rogue

    Enclose the perm nodes in quotes

    Code:java
    1. if (sender.hasPermission("ZillaBans.ban")) {
    2. // do command
    3. } else {
    4. // don't do command
    5. }


    Also:

    I don't recommend using capitals in perm nodes

    You should check the perm node before running the command, not after.
     
  4. Offline

    PolarCraft

    1Rogue Already said above ^ :D
     
  5. Offline

    TheCombatCA

    you can also use this for players that don't have the permission:
    Code:java
    1. if(!(player.hasPermission("Permission.perm")){
    2. player.sendMessage("You do not have Permission to use this Command!");
    3. return true;
    4. }


    use this for players that have permission:
    Code:java
    1. if(player.hasPermission("Permission.perm")){
    2. Put your code here
    3. return true;
    4. }
     
  6. Offline

    PolarCraft

    TheCombatCA that would not work. For the you do not have permission you would use:
    Code:java
    1. if (args[0].equalsIgnoreCase("test")) {
    2. if (sender.hasPermission("example.test")) {
    3. //CODE HERE
    4. } else {
    5. sender.sendMessage(ChatColor.RED + "NICE TRY!");
    6. }
     
Thread Status:
Not open for further replies.

Share This Page