Permissions [Need Help]

Discussion in 'Plugin Development' started by VitaminBoy, Jun 11, 2012.

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

    VitaminBoy

    Ive got this code

    Code:
    if(commandlabel.equalsIgnoreCase("healme") && sender.hasPermission("SimpleCommands.healme")
                    || commandlabel.equalsIgnoreCase("hm")) {
            }else{
                sender.sendMessage(PREFIX + ":" + getConfig().getString("Healme Message").replace("´NEWLINE", NEWLINE).replaceAll("´BLACK", BLACK + "").replaceAll("´DARKBLUE", DARKBLUE + "").replaceAll("´DARKGREEN", DARKGREEN + "").replaceAll("´DARKAQUA", DARKAQUA + "").replaceAll("´DARKRED", DARKRED + "").replaceAll("´DARKPURPLE", DARKPURPLE + "").replaceAll("´PURPLE", PURPLE + "").replaceAll("´GOLD", GOLD + "").replaceAll("´GRAY", GRAY + "").replaceAll("´DARKGRAY", DARKGRAY + "").replaceAll("´GREEN", GREEN + "").replaceAll("´AQUA", AQUA + "").replaceAll("´RED", RED + "").replaceAll("´YELLOW", YELLOW + "").replaceAll("´WHITE", WHITE + ""));
                player.setHealth(20);           
                player.sendMessage(PREFIX + ":" + getConfig().getString("Healme Message").replace("´NEWLINE", NEWLINE).replaceAll("´BLACK", BLACK + "").replaceAll("´DARKBLUE", DARKBLUE + "").replaceAll("´DARKGREEN", DARKGREEN + "").replaceAll("´DARKAQUA", DARKAQUA + "").replaceAll("´DARKRED", DARKRED + "").replaceAll("´DARKPURPLE", DARKPURPLE + "").replaceAll("´PURPLE", PURPLE + "").replaceAll("´GOLD", GOLD + "").replaceAll("´GRAY", GRAY + "").replaceAll("´DARKGRAY", DARKGRAY + "").replaceAll("´GREEN", GREEN + "").replaceAll("´AQUA", AQUA + "").replaceAll("´RED", RED + "").replaceAll("´YELLOW", YELLOW + "").replaceAll("´WHITE", WHITE + ""));
    and the output is Nothing. I wanna know when player does not have the required permission then server prints out You do not have Permission! So i just need a code.
     
  2. Offline

    Briggybros

    Code:
        if(commandlabel.equalsIgnoreCase("healme") || commandlabel.equalsIgnoreCase("hm"))
        {
            if(sender.hasPermission("SimpleCommands.healme"))
            {
                player.setHealth(20); 
            }
            else
            {
                sender.sendMessage(ChatColor.RED + "You do not have the required permissions.");
            }
        }
        else
        {
            return false;
        }
     
  3. Offline

    Spicyfish

    It almost looks as if you have your code the wrong way around, you're saying:

    If the command is healme and the person has the permission {
    // Nothing here
    }
    else {
    Heal the player
    }

    I've never really made a plugin before, I'm just going over your code pseudo wise, but I'm guessing that's the problem.

    Edit: beat me to it, lol
     
  4. Offline

    Briggybros

    Yes, you are right with your analysis
     
  5. Offline

    VitaminBoy

    That does not show the Message "You do not have the required permissions."
     
  6. Offline

    Briggybros

    It should do, are you testing it with the permission?
     
Thread Status:
Not open for further replies.

Share This Page